Created
April 20, 2020 02:49
-
-
Save sofyan-ahmad/00ddc719035d9efd4801be575ebf2b14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
export const getSignedURL = async ( | |
url: string, | |
file: File | |
): Promise<{ fileName: string; s3Url: string }> => { | |
try { | |
const endpoint = url; | |
const payload = { | |
filePath: file.name, | |
contentType: file.type, | |
fileSize: file.size, | |
}; | |
const { data } = await axios.post(endpoint, payload); | |
return data as any; | |
} catch (err) { | |
if (err.response) { | |
throw err.response; | |
} | |
throw err; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment