Chunked File Upload SupportPage edited by Shashank GuptaChanges (24)
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="catalog.pdf" Content-Type: application/octet-stream Content-Transfer-Encoding: binary $binarydata [response] First 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: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="catalog.pdf" 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>
Last chunk uploadTo indicate the last chunk, client additionally pass ":lastChunk" to true in request parameter. In last chunk upload response, the changelog has all the modification made in the repository. Last chunk upload request POST /content/dam HTTP/1.1 Authorization: Basic YWRtaW46YWRtaW4= Transfer-Encoding: chunked Content-Type: multipart/form-data; boundary=XHnea0Y5RY92mJwpnKXHfl0dfhcqOCe Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1 (java 1.5) Host: localhost:4502 --XHnea0Y5RY92mJwpnKXHfl0dfhcqOCe Content-Disposition: form-data; name=":lastChunk" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit true --XHnea0Y5RY92mJwpnKXHfl0dfhcqOCe Content-Disposition: form-data; name=":chunkNumber" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6 --XHnea0Y5RY92mJwpnKXHfl0dfhcqOCe Content-Disposition: form-data; name=":chunkUploadId" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /tmp/sling/chunks/21d36856b76045da8719ac932f88fe08 --XHnea0Y5RY92mJwpnKXHfl0dfhcqOCe Content-Disposition: form-data; name="*"; filename="catalog.pdf" Content-Type: application/octet-stream Content-Transfer-Encoding: binary $binarydata [response] Last 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 /content/dam</title>
</head>
<body>
<h1>Content modified /content/dam</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">"/content/dam" id="Location">/content/dam</a></td>
</tr>
<tr>
<td>Parent Location</td>
<td><a href="" class="code-quote">"/content" id="ParentLocation">/content</a></td>
</tr>
<tr>
<td>Path</td>
<td><div id="Path">/content/dam</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>created("/content/dam/catalog.pdf");<br/>created("/content/dam/catalog.pdf/jcr:content");<br/>modified("/content/dam/catalog.pdf/jcr:content/jcr:lastModified");<br/>modified("/content/dam/catalog.pdf/jcr:content/jcr:mimeType");<br/>modified("/content/dam/catalog.pdf/jcr:content/jcr:data");<br/></pre></div></td>
</tr>
</tbody>
</table>
<p><a href="">Go Back</a></p>
<p><a href="" class="code-quote">"/content/dam">Modified Resource</a></p>
<p><a href="" class="code-quote">"/content">Parent of Modified Resource</a></p>
</body>
</html
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
