The most straightforward method for uploading a file is by making a simple upload request. This option is a good choice when:
To use simple upload, make a POST
or PUT
request to the upload method's URI and add the query parameter uploadType=simple
.
The HTTP headers to use when making a simple upload request include:
Content-Type
. Set the media content-type.Content-Length
. Set to the number of bytes you are uploading.The following example shows the use of a simple photo upload request for an upload path that would be /upload
:
POST /upload?uploadType=simple HTTP/1.1 Host: www.example.com Content-Type: image/jpeg Content-Length: number_of_bytes_in_JPEG_file JPEG data
If the request succeeds, the server returns the HTTP 200 OK status code along with any metadata:
HTTP/1.1 200 Content-Type: application/json { "field": "value" }