aboutsummaryrefslogtreecommitdiff
path: root/src/services
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-06-30 15:32:52 -0400
committerIvan Chen <ivan@tagg.id>2021-06-30 15:32:52 -0400
commita8c210165938cfa4da7ed6bc185af297d528d2aa (patch)
tree7ec1e7ce832d1d2933f6781e24e712d543901ea0 /src/services
parentc548f8df62c3775058ffa18e201ca230a641e6c1 (diff)
Remove filename requirement for all moment upload
Diffstat (limited to 'src/services')
-rw-r--r--src/services/MomentService.ts21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/services/MomentService.ts b/src/services/MomentService.ts
index b274ef04..ad0b0042 100644
--- a/src/services/MomentService.ts
+++ b/src/services/MomentService.ts
@@ -6,6 +6,7 @@ import {
MOMENT_TAGS_ENDPOINT,
MOMENT_THUMBNAIL_ENDPOINT,
PRESIGNED_URL_ENDPOINT,
+ RADIO_BUTTON_GREY,
TAGG_CUSTOMER_SUPPORT,
} from '../constants';
import {
@@ -16,7 +17,6 @@ import {MomentPostType, MomentTagType, PresignedURLResponse} from '../types';
import {checkImageUploadStatus} from '../utils';
export const postMoment = async (
- fileName: string,
uri: string,
caption: string,
category: string,
@@ -25,13 +25,9 @@ export const postMoment = async (
try {
const request = new FormData();
- //Manipulating filename to end with .jpg instead of .heic
- if (fileName.endsWith('.heic') || fileName.endsWith('.HEIC')) {
- fileName = fileName.split('.')[0] + '.jpg';
- }
request.append('image', {
uri: uri,
- name: fileName,
+ name: 'moment.jpg', // we don't care about filename, anything works
type: 'image/jpg',
});
request.append('moment', category);
@@ -219,14 +215,13 @@ export const deleteMomentTag = async (moment_tag_id: string) => {
* This function makes a request to the server in order to provide the client with a presigned URL.
* This is called first, in order for the client to directly upload a file to S3
* @param value: string | undefined
- * @param filename: string | undefined
* @returns a PresignedURLResponse object
*/
-export const handlePresignedURL = async (
- filename: string | undefined,
- momentCategory: string,
-) => {
+export const handlePresignedURL = async (momentCategory: string) => {
try {
+ // TODO: just a random filename for video poc, we should not need to once complete
+ const randHash = Math.random().toString(36).substring(7);
+ const filename = `[pc_${randHash}].mov`;
const token = await AsyncStorage.getItem('token');
const response = await fetch(PRESIGNED_URL_ENDPOINT, {
method: 'POST',
@@ -260,13 +255,11 @@ 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 filename: the filename
* @param filePath: the path to the file, including filename
* @param urlObj PresignedURLResponse | undefined
* @returns responseURL or boolean
*/
export const handleVideoUpload = async (
- filename: string,
filePath: string,
urlObj: PresignedURLResponse | undefined,
) => {
@@ -297,7 +290,7 @@ export const handleVideoUpload = async (
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: 'moment.mov', // we don't care about filename, anything works
});
const response = await fetch(urlObj.response_url.url, {
method: 'POST',