aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/moments/Moment.tsx31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/components/moments/Moment.tsx b/src/components/moments/Moment.tsx
index 91c14f7d..cd76f36c 100644
--- a/src/components/moments/Moment.tsx
+++ b/src/components/moments/Moment.tsx
@@ -55,13 +55,17 @@ const Moment: React.FC<MomentProps> = ({
user: {userId},
} = useSelector((state: RootState) => state.user);
- const uploadVideo = async (filename: string, filePath: string) => {
- let presignedURL = await handlePresignedURL(filename, title);
- console.log('presigned' + JSON.stringify(presignedURL));
- Alert.alert('Uploading...');
- await handleVideoUpload(filename, filePath, presignedURL);
- Alert.alert('Finish uploading, refreshing moments...');
- dispatch(loadUserMoments(userId));
+ const uploadVideo = async (filePath: string) => {
+ const randHash = Math.random().toString(36).substring(7);
+ const filename = `poc_${randHash}.mov`;
+ const presignedURL = await handlePresignedURL(filename, title);
+ if (presignedURL) {
+ console.log('presigned' + JSON.stringify(presignedURL));
+ Alert.alert('Upload begin in background...');
+ await handleVideoUpload(filename, filePath, presignedURL);
+ Alert.alert('Finish uploading, refreshing moments...');
+ dispatch(loadUserMoments(userId));
+ }
};
/**
* This function opens the ImagePicker, only lets you select video files,
@@ -86,7 +90,7 @@ const Moment: React.FC<MomentProps> = ({
if ('path' in vid) {
console.log(vid);
if (vid.filename && vid.sourceURL) {
- uploadVideo(vid.filename, vid.sourceURL);
+ uploadVideo(vid.sourceURL);
}
}
})
@@ -177,13 +181,16 @@ const Moment: React.FC<MomentProps> = ({
{
mediaType: 'video',
durationLimit: 60,
- videoQuality: 'medium',
},
(response) => {
console.log(response);
- const file = response.assets[0];
- // TODO: not tested
- uploadVideo(file.fileName, file.uri);
+ if (
+ response.assets &&
+ response.assets.length !== 0 &&
+ response.assets[0].uri
+ ) {
+ uploadVideo(response.assets[0].uri);
+ }
},
),
},