<< Back to Tvider API Documentation
multipartUpload
Uploads a media file using multipart approach.
URL:
http://chunk-upload.tvider.com/api/multipartUpload
HTTP Method:
POST
Requires Authentication:
false
Parameters: (to be sent in POST request body)
- file - This is basically the full path(including name and extension) of the media file, obtained through the 'file' field in an HTML page. In other cases, this can be the binary data of the file.
Usage notes:
- POST request body:
- When web browser is used: This is obtained from 'file' field in the HTML page. (as specified in Parameters for file.)
- When web browser is not used: The headers need to be appended in binary form, before the binary data of file; so as to make it appear as form data. There should be a boundary on either side of the final binary data.
Eg.: String newLine = "\r\n" ;
String string_boundary = "-------boundary123456" ; (can be any random string)
String formHeaders = string_boundary + newLine ;
formHeaders = formHeaders + "Content-Disposition: form-data; name=Filename" + newLine ;
formHeaders = formHeaders + string_boundary + newLine ;
formHeaders = formHeaders + "Content-Disposition: form-data; name=Filedata; filename=\"" ;
formHeaders = formHeaders + fileName + "\"" + newLine ; // fileName includes extension
formHeaders = formHeaders + "Content-Type: " + contentMimeType + newLine + newLine ;
byteArrayOutputStream.write( formHeaders.getBytes() ) ;
byteArrayOutputStream.write( fileBinaryData ) ;
byteArrayOutputStream.write( (newLine + string_boundary + newLine).getBytes() ) ;
byte[] postRequest = byteArrayOutputStream.toByteArray() ;
- Encoding type header: (Required only when web browser is used.)
Key: "enctype"
Value: "multipart/form-data"
(When web browser is used)
Key: "Content-Type"
Value: contentMimeType
(When web browser is not used)
Key: "Content-Type"
Value: "multipart/form-data; boundary=" + string_boundary
- Content-Length header: (Required only when web browser is not used.)
Key: "Content-Length"
Value: length of post request body
Response:
- In case file is successfully uploaded:
{"result":
{"uploadStatus":"File is successfully uploaded.",
"uploadedFileLength":4409,
"mediaId":4122
},
"error":null,
"responseTime":"Response Time: 0.0 s"
}
<< Back to Tvider API Documentation
Comments (0)
You don't have permission to comment on this page.