URL | https://<server domain name>/api/core/<version>/File/ |
Description | Allows a user to post a file for the given entity within a given parent folder.
This endpoint is a multipart/form-data post consisting of two key value fields (json and file), where the value’s are tuples. |
Required components for multipart/form data (json field) | Type | Description |
Key Field:
Field name |
String | “json” |
Key Values: | ||
Name | String | Empty/None |
Json values
Required parameters |
String | Json string with following parameters |
name | String | Filename to upload |
primaryDomainKey | String | The guid of the entity e.g.clientId |
size | string | File size in bytes |
entity | String | Type of entity to upload to e.g.client
(Only client entity is supported currently) |
Optional Parameters | ||
parentFolderId | String | The guid of the folder to which the file needs to be uploaded. If left blank it will be uploaded to root level |
isFolder | Bool | Should be False for a File upload |
Required components (File field part) | Type | Description |
Key Field:
Field name |
String | “File” |
Key Values:
File Components |
||
name | String | Name of the file being uploaded |
File | String | The byte string stream as plain text for an file opened as binary |
Content type | String | Text/plain (text/plain will work for all file types) |
* Note that the header in the request will be a content type of “multipart/form-data” and will contain a calculated boundary value (other coreplus endpoint requests use application/json as the content-type)
It is best to use a multipart encoder library to generate the payload data into a single string.
e.g Python library Multipart Encoder http://toolbelt.readthedocs.io/en/latest/uploading-data.html
C# should be able to do this with the Microsoft.Net.Http package https://stackoverflow.com/questions/566462/upload-files-with-httpwebrequest-multipart-form-data
Example Request | https://api.coreplus.com.au/API/Core/v2.1/File/ |
Json Part | json: (None, ‘{“parentFolderId”: null, “name”: “UploadFile.txt”, “size”: “38”, “isFolder”: false, “entity”: “Client”, “primaryDomainKey”: “88e372b5-e985-4084-8f69-c888f995fbcc”}’, ‘text/plain’) |
File Part | file: (‘UploadFile.txt’, <_io.BufferedReader name=’D:\\UploadFile.txt’>, ‘text/plain’) where <_io.BufferedReader is the stream output from the file opened in binary mode |
Example Response |
|