aboutsummaryrefslogtreecommitdiff
path: root/src/services/MomentService.ts
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-06-22 19:14:06 -0400
committerIvan Chen <ivan@tagg.id>2021-06-22 19:14:06 -0400
commitab13c937f1de947e68df03b443cf9fccb0cd54c9 (patch)
tree7d3a15e53c37a1420bc60d55db28f21eda0d1d95 /src/services/MomentService.ts
parent0561794c67d827c918029f2e06572fd03b4531fd (diff)
Add alert for gallery and camera
Diffstat (limited to 'src/services/MomentService.ts')
-rw-r--r--src/services/MomentService.ts15
1 files changed, 6 insertions, 9 deletions
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',