[Geoserver-devel] [JIRA] (GEOS-8998) File upload via /rest/resource interface results in unusable files.

Miodrag Vidanovic created an issue

GeoServer / BugGEOS-8998

File upload via /rest/resource interface results in unusable files.

Issue Type:

BugBug

Affects Versions:

2.13.1, 2.13.2, 2.14.0

Assignee:

Unassigned

Components:

REST

Created:

05/Nov/18 4:01 PM

Environment:

GeoServer 2.14.0 running on Ubuntu 16.04 LTS
Tested also on GeoServer 2.13.1 and 2.13.2, with same results.

Priority:

HighHigh

Reporter:

Miodrag Vidanovic

Upload of any kind of file via rest API PUT /rest/resource/<path to file> leaves this file unusable.
The upload itself is successful, request returns 200 http status code, the file is saved there where it is supposed to land, but the content of the file is still wrapped in http multipart body envelope and therefore cannot be parsed.
Only one file is uploaded per request. It does not matter if it is clear text or binary file, the effect is the same. The file being uploaded is not a zip file, so no auto-extracting is involved.

Steps to reproduce:

  1. create an empty json file called test.json and paste following content inside:
{
    "overviewMapZoomLevel": 0,
    "mainMapZoomLevels": [1, 2, 3, 4, 5, 6],
    "proj4text": "+proj=utm +zone=32 +datum=WGS84 +units=m +no_defs"
}

  1. upload that file to a already existing workspace “topp” using /rest/resource rest API:
curl -XPUT -u admin:geoserver -F "test_file=@test.json" http://localhost:8080/geoserver/rest/resource/workspaces/topp/test.json

  1. now go to the data_dir/workspaces/topp directory and you will find test.json with it’s content wrapped, like this:
--------------------------7ed6c38755c81721
Content-Disposition: form-data; name="service_config"; filename="service_config.json"
Content-Type: application/octet-stream

{
    "overviewMapZoomLevel": 0,
    "mainMapZoomLevels": [1, 2, 3, 4, 5, 6],
    "proj4text": "+proj=utm +zone=32 +datum=WGS84 +units=m +no_defs"
}
--------------------------7ed6c38755c81721--

Add Comment

Add Comment

Get Jira notifications on your phone! Download the Jira Cloud app for Android or iOS


This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100095-sha1:e49d174)

Atlassian logo

You need to set your content-type to be application/json. But GeoServer
should probably either throw an exception if passed form encoded data or
unpack it, but not sure if we would know what format it is inside in that
case?

(attachments)

jira-generated-image-static-comment-icon-e9033cfa-3467-42a4-b538-51dee8145d33.png
jira-generated-image-static-high-c73a9520-3c2f-486c-b6a5-e29b9b9b9f50.png
noname.png
jira-generated-image-static-footer-desktop-logo-69c894ba-aed2-4a3e-9c96-39c67562529d.png