Chunked File Upload SupportPage edited by Shashank GuptaChanges (3)
Full ContentChunked File UploadStatus: DRAFT Use Cases:1. Large file upload - With high speed internet connections, advent of cloud and HD going mainstream, Sling support large files (> 2GB) upload. ApproachSling provides an extension to SlingPostServlet which accepts file chunks in accordance with a specified protocol. Sling client slices the file in chunks, and upload the chunks in serial manner to server. Each chunk is numbered serially and the last chunk has additional identifier to distinguish from the rest chunks. SlingPostServletupon receiving the last chunk, stitches all chunks into a single file and creates node tree in repository. In case of upload failures, sling provides support to query the last chunk uploaded till failure point. Client resumes chunk upload from last failure point. Protocol SpecificationUpload chunk using POSTFirst chunk uploadClient uses POST method to parent path to upload binary chunk of file. Client passes ":chunkNumber" and "fileName" as multipart request parameters. First chunk upload request POST /content/dam HTTP/1.1 Authorization: Basic YWRtaW46YWRtaW4= Transfer-Encoding: chunked Content-Type: multipart/form-data; boundary=v0_zWJbImtVo0uK-bJWayWUiT3zTBIj6 Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1 (java 1.5) Host: localhost:4502 --v0_zWJbImtVo0uK-bJWayWUiT3zTBIj6 Content-Disposition: form-data; name=":chunkNumber" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1 --v0_zWJbImtVo0uK-bJWayWUiT3zTBIj6 Content-Disposition: form-data; name="*"; filename="$filename" Content-Type: application/octet-stream Content-Transfer-Encoding: binary $binarydata [response] First chunk upload response
TTP/1.1 200 OK
Connection: Keep-Alive
Server: Day-Servlet-Engine/4.1.42
Content-Type: text/html;charset=UTF-8
Date: Thu, 28 Feb 2013 14:14:24 GMT
Transfer-Encoding: chunked
<html>
<head>
<title>Content modified /tmp/sling/chunks</title>
</head>
<body>
<h1>Content modified /tmp/sling/chunks</h1>
<table>
<tbody>
<tr>
<td>Status</td>
<td><div id="Status">200</div></td>
</tr>
<tr>
<td>Message</td>
<td><div id="Message">OK</div></td>
</tr>
<tr>
<td>Location</td>
<td><a href="" class="code-quote">"/tmp/sling/chunks/21d36856b76045da8719ac932f88fe08" id="Location">/tmp/sling/chunks/21d36856b76045da8719ac932f88fe08</a></td>
</tr>
<tr>
<td>Parent Location</td>
<td><a href="" class="code-quote">"/tmp/sling/chunks" id="ParentLocation">/tmp/sling/chunks</a></td>
</tr>
<tr>
<td>Path</td>
<td><div id="Path">/tmp/sling/chunks</div></td>
</tr>
<tr>
<td>Referer</td>
<td><a href="" class="code-quote">"" id="Referer"></a></td>
</tr>
<tr>
<td>ChangeLog</td>
<td><div id="ChangeLog"><pre></pre></div></td>
</tr>
</tbody>
</table>
<p><a href="">Go Back</a></p>
<p><a href="" class="code-quote">"/tmp/sling/chunks/21d36856b76045da8719ac932f88fe08">Modified Resource</a></p>
<p><a href="" class="code-quote">"/tmp/sling/chunks">Parent of Modified Resource</a></p>
</body>
</html>
The location tag contains unique chunk upload id which need to be passed on subsequent request. Intermediate chunk uploadClient require to additionally pass chunk upload id Intermediate chunk upload request POST /content/dam HTTP/1.1 Authorization: Basic YWRtaW46YWRtaW4= Transfer-Encoding: chunked Content-Type: multipart/form-data; boundary=F1MYdmO-MYq-wLW2P2tWIu-7KUH3-r Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1 (java 1.5) Host: localhost:4502 --F1MYdmO-MYq-wLW2P2tWIu-7KUH3-r Content-Disposition: form-data; name=":chunkNumber" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 3 --F1MYdmO-MYq-wLW2P2tWIu-7KUH3-r Content-Disposition: form-data; name=":chunkUploadId" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /tmp/sling/chunks/21d36856b76045da8719ac932f88fe08 --F1MYdmO-MYq-wLW2P2tWIu-7KUH3-r Content-Disposition: form-data; name="*"; filename="$filename" Content-Type: application/octet-stream Content-Transfer-Encoding: binary $binarydata [response] Intermediate chunk upload response
HTTP/1.1 200 OK
Connection: Keep-Alive
Server: Day-Servlet-Engine/4.1.42
Content-Type: text/html;charset=UTF-8
Date: Thu, 28 Feb 2013 14:14:25 GMT
Transfer-Encoding: chunked
<html>
<head>
<title>Content modified /tmp/sling/chunks</title>
</head>
<body>
<h1>Content modified /tmp/sling/chunks</h1>
<table>
<tbody>
<tr>
<td>Status</td>
<td><div id="Status">200</div></td>
</tr>
<tr>
<td>Message</td>
<td><div id="Message">OK</div></td>
</tr>
<tr>
<td>Location</td>
<td><a href="" class="code-quote">"/tmp/sling/chunks/21d36856b76045da8719ac932f88fe08" id="Location">/tmp/sling/chunks/21d36856b76045da8719ac932f88fe08</a></td>
</tr>
<tr>
<td>Parent Location</td>
<td><a href="" class="code-quote">"/tmp/sling/chunks" id="ParentLocation">/tmp/sling/chunks</a></td>
</tr>
<tr>
<td>Path</td>
<td><div id="Path">/tmp/sling/chunks</div></td>
</tr>
<tr>
<td>Referer</td>
<td><a href="" class="code-quote">"" id="Referer"></a></td>
</tr>
<tr>
<td>ChangeLog</td>
<td><div id="ChangeLog"><pre></pre></div></td>
</tr>
</tbody>
</table>
<p><a href="">Go Back</a></p>
<p><a href="" class="code-quote">"/tmp/sling/chunks/21d36856b76045da8719ac932f88fe08">Modified Resource</a></p>
<p><a href="" class="code-quote">"/tmp/sling/chunks">Parent of Modified Resource</a></p>
</body>
</html>
Upload of last chunkClient appends "/last" to upload url to signify that it would be last that needs to be uploaded. The last chunk upload request can optionally be multipart request if client requires to send additional parameters to sling. [request] Upload last chunk request POST /content/dam/dam-folder/catalog.pdf.chunk.<chunk_number>.res/last HTTP/1.1 Host: localhost:4502 Date: <date> Content-type: multipart/form-data, boundary=AaB03x --AaB03x content-disposition: form-data; name="fileSize" 210000000 --AaB03x content-disposition: form-data; name="file"; fileName="catalog.pdf" Content-Type: application/pdf Content-Transfer-Encoding: binary $binarydata --AaB03x-- [response] Upload last chunk response HTTP/1.1 201/CREATED Content-Length: 0 Location: /content/dam/dam-folder/catalog.pdf Content-MD5: $md5_hash Connection: close The location header provides location of fully uploaded asset.The response contains the $md5_hash of merged binary. Upload chunk using PATCHSling support three patch formats to upload chunks on sling. All other semantics remain same as Upload chunk using POST
Query to retrieve last successful chunk uploadReturns the number of last chunk upload and bytes uploaded successfully on sling. Get last successful chunk upload request GET /content/dam/dam-folder/catalog.pdf.chunk.json HTTP/1.1 Host: localhost:4502 Date: <date> Content-Length: 0 [response] Get last successful upload chunk response
HTTP/1.1 200/OK
Connection: close
{
"chunkNumber": 8
"bytesuploaded": 19872
}
If no broken/discontinued upload sling returns 404 not found response. Chunked upload not found response HTTP/1.1 404/Not Found Abort chunked upload[request] Abort chunked upload Request DELETE /content/dam/dam-folder/catalog.pdf.chunk.res HTTP/1.1 Host: localhost:4502 Date: <date> [response] Abort chunked upload response HTTP/1.1 200/OK Connection: close
Change Notification Preferences
View Online
|
View Changes
|
Add Comment
|
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
- [CONF] Apache Sling > Chunked File Upload Support confluence
