@noatgnu/cupcake-vanilla 1.2.4 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1763,13 +1763,14 @@ class ChunkedUploadService extends BaseApiService {
|
|
|
1763
1763
|
? `${this.apiUrl}/chunked-upload/${uploadId}/`
|
|
1764
1764
|
: `${this.apiUrl}/chunked-upload/`;
|
|
1765
1765
|
const httpOptions = {};
|
|
1766
|
-
|
|
1766
|
+
const isChunkedUpload = offset !== undefined && totalSize !== undefined;
|
|
1767
|
+
if (isChunkedUpload) {
|
|
1767
1768
|
const chunkEnd = offset + request.file.size - 1;
|
|
1768
1769
|
httpOptions.headers = {
|
|
1769
1770
|
'Content-Range': `bytes ${offset}-${chunkEnd}/${totalSize}`
|
|
1770
1771
|
};
|
|
1771
1772
|
}
|
|
1772
|
-
if (uploadId) {
|
|
1773
|
+
if (isChunkedUpload || uploadId) {
|
|
1773
1774
|
return this.put(url, formData, httpOptions);
|
|
1774
1775
|
}
|
|
1775
1776
|
else {
|
|
@@ -1805,17 +1806,16 @@ class ChunkedUploadService extends BaseApiService {
|
|
|
1805
1806
|
* Complete the chunked upload by uploading the entire file at once
|
|
1806
1807
|
*/
|
|
1807
1808
|
completeUploadWithFile(request) {
|
|
1808
|
-
const formData = new FormData();
|
|
1809
|
-
formData.append('file', request.file);
|
|
1810
|
-
if (request.filename) {
|
|
1811
|
-
formData.append('filename', request.filename);
|
|
1812
|
-
}
|
|
1813
1809
|
const hasher = new jsSHA('SHA-256', 'ARRAYBUFFER');
|
|
1814
1810
|
const arrayBufferPromise = request.file.arrayBuffer();
|
|
1815
1811
|
return from(arrayBufferPromise).pipe(switchMap((arrayBuffer) => {
|
|
1816
1812
|
hasher.update(arrayBuffer);
|
|
1817
1813
|
const hash = hasher.getHash('HEX');
|
|
1818
|
-
formData
|
|
1814
|
+
const formData = new FormData();
|
|
1815
|
+
formData.append('file', request.file);
|
|
1816
|
+
if (request.filename) {
|
|
1817
|
+
formData.append('filename', request.filename);
|
|
1818
|
+
}
|
|
1819
1819
|
if (request.uploadSessionId) {
|
|
1820
1820
|
formData.append('upload_session_id', request.uploadSessionId);
|
|
1821
1821
|
}
|
|
@@ -1828,6 +1828,7 @@ class ChunkedUploadService extends BaseApiService {
|
|
|
1828
1828
|
if (request.replaceExisting !== undefined) {
|
|
1829
1829
|
formData.append('replace_existing', request.replaceExisting.toString());
|
|
1830
1830
|
}
|
|
1831
|
+
formData.append('sha256', hash);
|
|
1831
1832
|
return this.post(`${this.apiUrl}/chunked-upload/`, formData);
|
|
1832
1833
|
}));
|
|
1833
1834
|
}
|