2020-03-10 11:03:52 +00:00
|
|
|
## Upload Data
|
2020-03-10 10:55:27 +00:00
|
|
|
If the user wants to upload custom data (lutum/ec) they can use the FarmMaps file API.
|
|
|
|
The API is based on the google drive API.
|
|
|
|
|
2020-03-20 14:30:27 +00:00
|
|
|
C# explanation:
|
|
|
|
https://developers.google.com/api-client-library/dotnet/guide/media_upload
|
|
|
|
https://developers.google.com/drive/api/v3/manage-uploads#resumable
|
2020-03-18 13:11:36 +00:00
|
|
|
|
2020-03-10 10:55:27 +00:00
|
|
|
* Start request
|
|
|
|
|
|
|
|
> Request
|
|
|
|
```javascript
|
|
|
|
POST https://farmmaps.awacc.nl/api/v1/file
|
|
|
|
|
|
|
|
Host: farmmaps.awtest.nl
|
|
|
|
Authorization: Bearer < Token >
|
|
|
|
X-Upload-Content-Length: 13507747
|
|
|
|
X-Upload-Content-Type: application/x-zip-compressed
|
|
|
|
Content-Type: application/json; charset=UTF-8
|
|
|
|
Content-Length: 181
|
|
|
|
|
|
|
|
{
|
|
|
|
"name":"Grondsoorten2006-SHP.zip",
|
|
|
|
"mimeType":"application/x-zip-compressed",
|
|
|
|
"size":13507747,
|
|
|
|
"lastModified":1575293019617,
|
|
|
|
"parentCode":"c0787987a3f7449c97eecd6d015eb4c2:USER_FILES"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
> Response
|
|
|
|
```javascript
|
|
|
|
Location: /api/v1/file/2831cd05ddc0415784930059c658db55
|
|
|
|
Content-Length: 194
|
|
|
|
Content-Type: application/json; charset=utf-8
|
|
|
|
|
|
|
|
{
|
|
|
|
"code":"2831cd05ddc0415784930059c658db55",
|
|
|
|
"chunks":1,
|
|
|
|
"parentCode":"c0787987a3f7449c97eecd6d015eb4c2:USER_FILES",
|
|
|
|
"name":"Grondsoorten2006-SHP.zip",
|
|
|
|
"size":13507747,
|
|
|
|
"chunkSize":13507747,
|
|
|
|
"data":{}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
* Request upload chunk 1
|
|
|
|
|
|
|
|
> Request
|
|
|
|
```javascript
|
|
|
|
PUT https://farmmaps.awtest.nl/api/v1/file/2831cd05ddc0415784930059c658db55
|
|
|
|
|
|
|
|
Host: farmmaps.awtest.nl
|
|
|
|
Authorization: Bearer < Token >
|
|
|
|
Content-Type: application/octet-stream
|
|
|
|
Content-Length: 2097152
|
|
|
|
Content-Range: bytes 0-2097151/13507747
|
|
|
|
|
|
|
|
<data>
|
|
|
|
```
|
|
|
|
> Response
|
|
|
|
```javascript
|
|
|
|
HTTP/1.1 308 Resume Incomplete
|
|
|
|
|
|
|
|
Range: 0-2097151
|
|
|
|
Content-Length: 17
|
|
|
|
|
|
|
|
Resume Incomplete
|
|
|
|
```
|
|
|
|
|
|
|
|
* Request upload chunk 2
|
|
|
|
|
|
|
|
> Request
|
|
|
|
```javascript
|
|
|
|
PUT https://farmmaps.awtest.nl/api/v1/file/2831cd05ddc0415784930059c658db55
|
|
|
|
|
|
|
|
Host: farmmaps.awtest.nl
|
|
|
|
Authorization: Bearer < Token >
|
|
|
|
Content-Type: application/octet-stream
|
|
|
|
Content-Length: 2097152
|
|
|
|
Content-Range: bytes 2097152-4194303/13507747
|
|
|
|
|
|
|
|
<data>
|
|
|
|
```
|
|
|
|
> Response
|
|
|
|
```javascript
|
|
|
|
HTTP/1.1 308 Resume Incomplete
|
|
|
|
|
|
|
|
Range: 0-4194303
|
|
|
|
Content-Length: 17
|
|
|
|
|
|
|
|
Resume Incomplete
|
|
|
|
```
|
|
|
|
|
|
|
|
* Final request
|
|
|
|
|
|
|
|
> Request
|
|
|
|
```javascript
|
|
|
|
PUT https://farmmaps.awtest.nl/api/v1/file/2831cd05ddc0415784930059c658db55
|
|
|
|
|
|
|
|
Host: farmmaps.awtest.nl
|
|
|
|
Authorization: Bearer < Token >
|
|
|
|
Content-Type: application/octet-stream
|
|
|
|
Content-Length: 924835
|
|
|
|
Content-Range: bytes 12582912-13507746/13507747
|
|
|
|
|
|
|
|
<data>
|
|
|
|
```
|
|
|
|
> Response
|
|
|
|
```javascript
|
|
|
|
Upload response laatste chunk
|
|
|
|
|
|
|
|
HTTP/1.1 201 Created
|
|
|
|
|
|
|
|
Range: 0-13507746
|
|
|
|
Content-Length: 0
|
|
|
|
```
|