Skip to content
Snippets Groups Projects
Commit e69fd032 authored by Jesper Zedlitz's avatar Jesper Zedlitz
Browse files

fehlenden mimetype tolerieren

Dateiname bei resource-create richtig als UTF-8 senden
parent f0edfd27
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<groupId>de.landsh.opendata</groupId> <groupId>de.landsh.opendata</groupId>
<artifactId>dcat-uploader</artifactId> <artifactId>dcat-uploader</artifactId>
<version>1.0</version> <version>1.0.2</version>
<build> <build>
<plugins> <plugins>
......
...@@ -328,7 +328,7 @@ public class CkanAPI { ...@@ -328,7 +328,7 @@ public class CkanAPI {
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.setCharset(StandardCharsets.UTF_8); builder.setCharset(StandardCharsets.UTF_8);
builder.addPart("package_id", new StringBody(packageId, ContentType.MULTIPART_FORM_DATA)); builder.addPart("package_id", new StringBody(packageId, ContentType.MULTIPART_FORM_DATA));
builder.addPart("name", new StringBody(name, ContentType.MULTIPART_FORM_DATA)); builder.addPart("name", new StringBody(name, ContentType.create("multipart/form-data", StandardCharsets.UTF_8)));
builder.addPart("format", new StringBody(format, ContentType.MULTIPART_FORM_DATA)); builder.addPart("format", new StringBody(format, ContentType.MULTIPART_FORM_DATA));
builder.addPart("upload", new FileBody(file, ContentType.create(mimeType), name)); builder.addPart("upload", new FileBody(file, ContentType.create(mimeType), name));
builder.addPart("hash", new StringBody(checksum, ContentType.MULTIPART_FORM_DATA)); builder.addPart("hash", new StringBody(checksum, ContentType.MULTIPART_FORM_DATA));
...@@ -365,7 +365,9 @@ public class CkanAPI { ...@@ -365,7 +365,9 @@ public class CkanAPI {
resource.setName(resourceJSON.getString("name")); resource.setName(resourceJSON.getString("name"));
resource.setChecksum(StringUtils.trimToNull(resourceJSON.getString("hash"))); resource.setChecksum(StringUtils.trimToNull(resourceJSON.getString("hash")));
resource.setFormat(resourceJSON.getString("format")); resource.setFormat(resourceJSON.getString("format"));
if (resourceJSON.has("mimetype") && !resourceJSON.isNull("mimetype")) {
resource.setMimeType(resourceJSON.getString("mimetype")); resource.setMimeType(resourceJSON.getString("mimetype"));
}
resource.setId(resourceJSON.getString("id")); resource.setId(resourceJSON.getString("id"));
resource.setByteSize(NumberUtils.toLong(Objects.toString(resourceJSON.get("size")))); resource.setByteSize(NumberUtils.toLong(Objects.toString(resourceJSON.get("size"))));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment