upload¶
Upload files to the storage system.
There are two ways to upload files:
Using a POST request it is possible to send multiple files at once,
but the request must be encapsulated as multipart/form-data
(Content-Type header must be multipart/form-data
) and it is necessary to specify the destination directory where the files should be stored.
Using a PUT request, only one file at the time can be uploaded. The file content must be included in the request body and it is necessary to specify the full path (directory with file name) where the file should be stored.
Note
In order to upload files, the token used must be enabled for such task.
GET¶
Caution
Not implemented. Will return a status code
of 501
.
POST¶
-
POST
/upload
¶ The destination directory is taken from the data form sent. It first checks if a
path
parameter is available, otherwise it tries to build the destination path with the other form parameters in the following way:job/git_branch/kernel/arch/[defconfig_full | defconfig ][/lab_name]
Caution
Sending multiple times the same files will overwrite the previous ones.
Form Parameters: - path – The destination directory where files should be saved.
- job – The job name.
- git_branch – The branch name.
- kernel – The kernel name.
- defconfig – The defconfig value.
- defconfig_full – The defconfig_full value.
- arch – The architecture type.
- lab_name – The boot lab name.
Response JSON Object: - code (int) – The status code of the request.
- result (array) – An array with the results of each file saved.
Response JSON Array of Objects: - status (int) – The status of the file saving operation (can be 200, 201, 500).
- bytes (int) – The bytes written to disk.
- error (string) – A string with the error reason, in case of errors.
- filename (string) – The name of the file as saved.
Request Headers: - Authorization – The token necessary to authorize the request.
- Content-Type – Content type of the transmitted data, must be
multipart/form-data
. - Accept-Encoding – Accept the
gzip
coding.
Response Headers: - Content-Type – Will be
application/json; charset=UTF-8
.
Status Codes: - 200 OK – The request has been processed.
- 400 Bad Request – Provided request is not valid.
- 403 Forbidden – Not authorized to perform the operation.
- 415 Unsupported Media Type – Wrong content type.
- 500 Internal Server Error – Internal error: cannot write directory, files, ...
Example Requests
POST /upload/ HTTP/1.1 Host: api.kernelci.org Authorization: token Accept: */* Content-Type: multipart/form-data; boundary=----------------------------80aa05d1f94c ------------------------------80aa05d1f94c Content-Disposition: form-data; name="path" next/next-20150116/arm-allnoconfig/ ------------------------------80aa05d1f94c Content-Disposition: form-data; name="file01"; filename="zImage" Content-Type: application/octet-stream
POST /upload/ HTTP/1.1 Host: api.kernelci.org Authorization: token Accept: */* Content-Type: multipart/form-data; boundary=----------------------------80aa05d1f94c ------------------------------80aa05d1f94c Content-Disposition: form-data; name="job" next ------------------------------80aa05d1f94c Content-Disposition: form-data; name="kernel" next-20150116 ------------------------------80aa05d1f94c Content-Disposition: form-data; name="arch" arm ------------------------------80aa05d1f94c Content-Disposition: form-data; name="arch" allnoconfig ------------------------------80aa05d1f94c Content-Disposition: form-data; name="file01"; filename="zImage" Content-Type: application/octet-stream
Example Responses
HTTP/1.1 200 OK Vary: Accept-Encoding Date: Fri, 16 Jan 2015 15:12:50 GMT Content-Type: application/json; charset=UTF-8 { "code": 200, "result": [ { "status": 200, "filename": "zImage", "error": null, "bytes": 6166840, } ] }
PUT¶
-
PUT
/upload/
(string: path)¶ Upload a single file at the specified
path
location.path
is the filename path where it should be stored. It will be treated like a file path. The file content should be sent in the request body.Parameters: - path – The destination path where the file should be saved.
Response JSON Object: - code (int) – The status code of the request.
- result (array) – An array with the results of each file saved.
Response JSON Array of Objects: - status (int) – The status of the file saving operation (can be 200, 201, 500).
- bytes (int) – The bytes written to disk.
- error (string) – A string with the error reason, in case of errors.
- filename (string) – The name of the file as saved.
Request Headers: - Authorization – The token necessary to authorize the request.
- Content-Type – Content type of the transmitted data, must be
multipart/form-data
. - Accept-Encoding – Accept the
gzip
coding.
Response Headers: - Content-Type – Will be
application/json; charset=UTF-8
.
Status Codes: - 200 OK – The file has been saved and the old one overwritten.
- 201 Created – The file has been saved.
- 400 Bad Request – Provided request is not valid.
- 403 Forbidden – Not authorized to perform the operation.
- 415 Unsupported Media Type – Wrong content type.
- 500 Internal Server Error – Internal error: cannot write directory, files, ...
Example Requests
PUT /upload/next/next-20150116/arm-allnoconfig/zImage HTTP/1.1 Host: api.kernelci.org Authorization: token Accept: */* Content-Length: 6166840 Content-Type: application/x-www-form-urlencoded .7zXZ......F..!.....GX:C..,..].....1.PX.3{...V...!...[.4....3..~ ...
Example Responses
HTTP/1.1 200 OK Vary: Accept-Encoding Date: Fri, 16 Jan 2015 15:12:50 GMT Content-Type: application/json; charset=UTF-8 { "code": 200, "result": [ { "status": 200, "filename": "zImage", "error": null, "bytes": 6166840, } ] }
DELETE¶
Caution
Not implemented. Will return a status code
of 501
.