From ab13c937f1de947e68df03b443cf9fccb0cd54c9 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 22 Jun 2021 19:14:06 -0400 Subject: Add alert for gallery and camera --- src/services/MomentService.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/services') diff --git a/src/services/MomentService.ts b/src/services/MomentService.ts index d0ed56ab..da6f9690 100644 --- a/src/services/MomentService.ts +++ b/src/services/MomentService.ts @@ -262,20 +262,17 @@ export const handlePresignedURL = async ( /** * This util function takes in the file object and the PresignedURLResponse object, creates form data from the latter, * and makes a post request to the presigned URL, sending the file object inside of the form data. - * @param file: Video, Image, Undefined + * @param filename: the filename + * @param filePath: the path to the file, including filename * @param urlObj PresignedURLResponse | undefined * @returns responseURL or boolean */ export const handleVideoUpload = async ( - file: Video | Image | undefined, + filename: string, + filePath: string, urlObj: PresignedURLResponse | undefined, ) => { try { - let fileName = file?.filename; - if (fileName === null || '') { - console.log('Invalid filename'); - return false; - } if (urlObj === null || urlObj === undefined) { console.log('Invalid urlObj'); return false; @@ -299,10 +296,10 @@ export const handleVideoUpload = async ( urlObj.response_url.fields['x-amz-signature'], ); form.append('file', { - uri: file?.sourceURL, + uri: filePath, // other types such as 'quicktime' 'image' etc exist, and we can programmatically type this, but for now sticking with simple 'video' type: 'video', - name: fileName, + name: filename, }); const response = await fetch(urlObj.response_url.url, { method: 'POST', -- cgit v1.2.3-70-g09d2