REST File API

The Rest File API can be used for uploading files to the Product Manager Server, e.g. for providing the source data of an import.

Uploading a File

URL Pattern

/manage/file

Method

POST

Parameters

originalFilename

Content types

binary/octet-stream

Returns

a file object containing the ID of the upload folder and the file name

Result

An object including an ID and a file name is returned, e.g.:

"originalFilename": "Data1.xls",
"id": "5b588807-5ad5-47db-a08b-3b3ca6573b41"

The file name is the same as provided in the parameter, the id represents the folder name the file has been stored in (under the upload directory of the Product Manager).

Examples

Uploading a file with file name Data1.xls

Rest Call
curl -u rest:heiler -H "Accept: application/json" -H "Content-Type:application/octet-stream" --data-binary "@Data.xlsx" -X POST http://localhost:1501/rest/V1.0/manage/file?originalFilename=Data.xls

An object including an ID and an URL is returned:

{
"id":"fc645958-b169-44eb-91df-6ce30b3c4b11",
"originalFilename":"Data.xls"
}
Rest Client Java Code
FileUploadRequest fileUploadRequest = restClient.createFileUploadRequest();
 
FileReference result = fileUploadRequest.uploadFile( "Data.xlsx", inputStream );

Uploading big files

When uploading big files with curl the -T command is recommended because the --data-binary command loads the complete file into memory and can lead to out of memory issues.

Using -T requires to send the header -H "Transfer-Encoding: chunked" in addition.

Rest Call
curl -u rest:heiler -H "Accept: application/json" -H "Content-Type:application/octet-stream" -H "Transfer-Encoding: chunked" -T "BigData.xlsx" -X POST "http://localhost:1501/rest/V1.0/manage/file?originalFilename=BigData.xlsx"