Skip to content

Commit

Permalink
Fix upload file naming
Browse files Browse the repository at this point in the history
  • Loading branch information
doctor-zob committed Aug 21, 2023
1 parent c103c44 commit 5fda07c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [1.0.5](https://github.com/SIMBAChain/libsimba4j-platform/compare/v1.0.4...v1.0.5) (2023-08-21)

### Fixes

* Fix file upload file names not being captured.


## [1.0.4](https://github.com/SIMBAChain/libsimba4j-platform/compare/v1.0.3...v1.0.4) (2023-06-24)

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.simbachain</groupId>
<artifactId>libsimba4j-platform</artifactId>
<version>1.0.5-SNAPSHOT</version>
<version>1.0.6-SNAPSHOT</version>
<name>LibSimba4J Blocks Platform</name>
<description>Java Client for SIMBA Chain Blocks Platform</description>
<url>https://simbachain.github.io/libsimba4j/</url>
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/com/simbachain/simba/SimbaClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,16 @@ protected HttpEntity createEntity(Map<String, Object> data, UploadFile... files)
builder.addTextBody(key, d.toString());

}
Map<String, String> names = new HashMap<>();
for (int i = 0; i < files.length; i++) {
UploadFile file = files[i];
builder.addBinaryBody(String.format("file_%s", i), file.getFile(),
String name = file.getName();
if(names.get(name) != null) {
name = String.format("%s_%s", i, name);
} else {
names.put(name, name);
}
builder.addBinaryBody(name, file.getFile(),
ContentType.create(file.getMimeType()), file.getName());
}
return builder.build();
Expand Down

0 comments on commit 5fda07c

Please sign in to comment.