Use Signed URLs to upload a file straight to Cloud Storage. It returns optimisticUrl to access the file once it is uploaded.
import signedUpload, { getUrls, upload } from '@pozible/signed-upload' const {optimisticUrl, signedUrl} = await getUrls(metadata, filePath, config) await upload(file, metadata, signedUrl) // Or bootstrap the two commands with const {optimisticUrl} = await signedUpload(file, metadata, filePath, config)dimensions attribute is used together with Cloud Function listening on bucket's changes to further process the image. Omit it when uploading generic files.
{ dimensions: { imageUrl: { width, height }, thumbUrl: { ... }, ... }, filename: 'original-filename.ext', mimetype: 'valid/type' }A function to provide a final path to the file in your bucket with uuid as a parameter to give random value to the file name. No need to add extension as it will be automatically added based on given filename in metadata.
const filePath = randomId => `/path/to/your/file-with-${randomId}` const filePath = () => `/path/to/your/original-file-name`baseUrl(optional): Add baseUrl to be added tooptimisticPathto form completeoptimisticUrl.bucketName: When it is deployed to Google Cloud Platform it will use current project, else specify one here.