We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add S3 signed url image upload example
signedURL should come from an api call to the API.
signedURL
import { create } from 'apisauce'; const uploadApi = create({ baseURL: '' }); const uploadFile = ({ signedURL, name, data, type, }) => const headers = { 'Content-Type': type }; return uploadApi.put(signedURL, data, { headers }).then(uploadResponse => { if (!uploadResponse.ok) { throw Error('errors.fileUpload'); } return response.data.url.split('?')[0]; }); });
const uploadFromFile = (file, resource) => uploadFile({ name: file.rawFile.name, data: file.rawFile, type: file.rawFile.type, resource });
const uploadImageFromBase64 = (src, resource, index) => { const blob = dataURItoBlob(src); return uploadFile({ name: `content_image_${index}.${blob.type.split('/')[1]}`, data: blob, type: blob.type, resource }); };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Summary
Add S3 signed url image upload example
Useful info
Creating an apisauce instance and uploading blob to S3
signedURL
should come from an api call to the API.Uploading from file
Uploading from base64
The text was updated successfully, but these errors were encountered: