|
@@ -12,6 +12,7 @@ import { getFileType } from 'services/typeDetectionService';
|
|
import { getLocalTrash, getTrashedFiles } from './trashService';
|
|
import { getLocalTrash, getTrashedFiles } from './trashService';
|
|
import { EncryptionResult, UploadURL } from 'types/upload';
|
|
import { EncryptionResult, UploadURL } from 'types/upload';
|
|
import { fileAttribute } from 'types/file';
|
|
import { fileAttribute } from 'types/file';
|
|
|
|
+import { USE_CF_PROXY } from 'constants/upload';
|
|
|
|
|
|
const ENDPOINT = getEndpoint();
|
|
const ENDPOINT = getEndpoint();
|
|
const REPLACE_THUMBNAIL_THRESHOLD = 500 * 1024; // 500KB
|
|
const REPLACE_THUMBNAIL_THRESHOLD = 500 * 1024; // 500KB
|
|
@@ -108,12 +109,20 @@ export async function uploadThumbnail(
|
|
): Promise<fileAttribute> {
|
|
): Promise<fileAttribute> {
|
|
const { file: encryptedThumbnail }: EncryptionResult =
|
|
const { file: encryptedThumbnail }: EncryptionResult =
|
|
await worker.encryptThumbnail(updatedThumbnail, fileKey);
|
|
await worker.encryptThumbnail(updatedThumbnail, fileKey);
|
|
-
|
|
|
|
- const thumbnailObjectKey = await uploadHttpClient.putFileV2(
|
|
|
|
- uploadURL,
|
|
|
|
- encryptedThumbnail.encryptedData as Uint8Array,
|
|
|
|
- () => {}
|
|
|
|
- );
|
|
|
|
|
|
+ let thumbnailObjectKey: string = null;
|
|
|
|
+ if (USE_CF_PROXY) {
|
|
|
|
+ thumbnailObjectKey = await uploadHttpClient.putFileV2(
|
|
|
|
+ uploadURL,
|
|
|
|
+ encryptedThumbnail.encryptedData as Uint8Array,
|
|
|
|
+ () => {}
|
|
|
|
+ );
|
|
|
|
+ } else {
|
|
|
|
+ thumbnailObjectKey = await uploadHttpClient.putFile(
|
|
|
|
+ uploadURL,
|
|
|
|
+ encryptedThumbnail.encryptedData as Uint8Array,
|
|
|
|
+ () => {}
|
|
|
|
+ );
|
|
|
|
+ }
|
|
return {
|
|
return {
|
|
objectKey: thumbnailObjectKey,
|
|
objectKey: thumbnailObjectKey,
|
|
decryptionHeader: encryptedThumbnail.decryptionHeader,
|
|
decryptionHeader: encryptedThumbnail.decryptionHeader,
|