@noatgnu/cupcake-vanilla 1.2.3 → 1.2.5

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.
@@ -1805,19 +1805,16 @@ class ChunkedUploadService extends BaseApiService {
1805
1805
  * Complete the chunked upload by uploading the entire file at once
1806
1806
  */
1807
1807
  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
1808
  const hasher = new jsSHA('SHA-256', 'ARRAYBUFFER');
1814
1809
  const arrayBufferPromise = request.file.arrayBuffer();
1815
- arrayBufferPromise.then(arrayBuffer => {
1810
+ return from(arrayBufferPromise).pipe(switchMap((arrayBuffer) => {
1816
1811
  hasher.update(arrayBuffer);
1817
- });
1818
- return from(arrayBufferPromise).pipe(switchMap(() => {
1819
1812
  const hash = hasher.getHash('HEX');
1820
- formData.append('sha256', hash);
1813
+ const formData = new FormData();
1814
+ formData.append('file', request.file);
1815
+ if (request.filename) {
1816
+ formData.append('filename', request.filename);
1817
+ }
1821
1818
  if (request.uploadSessionId) {
1822
1819
  formData.append('upload_session_id', request.uploadSessionId);
1823
1820
  }
@@ -1830,6 +1827,7 @@ class ChunkedUploadService extends BaseApiService {
1830
1827
  if (request.replaceExisting !== undefined) {
1831
1828
  formData.append('replace_existing', request.replaceExisting.toString());
1832
1829
  }
1830
+ formData.append('sha256', hash);
1833
1831
  return this.post(`${this.apiUrl}/chunked-upload/`, formData);
1834
1832
  }));
1835
1833
  }