Skip to content

Instantly share code, notes, and snippets.

@sofyan-ahmad
Created April 20, 2020 02:49
Show Gist options
  • Save sofyan-ahmad/00ddc719035d9efd4801be575ebf2b14 to your computer and use it in GitHub Desktop.
Save sofyan-ahmad/00ddc719035d9efd4801be575ebf2b14 to your computer and use it in GitHub Desktop.
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