Reputation: 352
upload a large(>40mb) m4a audio files to Google Cloud Storage(GCS)
Any idea how to get m4a files to upload?
# python backend
bucket = client.bucket(bucket_name)
blob = bucket.blob(filename)
signed_url = blob.generate_signed_url(
version="v4",
expiration=timedelta(minutes=60),
method="PUT",
)
// front end react JS
async function upload(file: File, signed_url: str) {
const formData = new FormData()
formData.append('file', file)
await axios.put(signed_url, formData, {
headers: {
'Content-Type': file.type
},
})
}
Upvotes: 0
Views: 89
Reputation: 352
dont use formdata. read up on this which is a slightly different problem: Uploading an MP3 using DropZone.js to Google Cloud Storage via signedUrl is corrupted
// front end react JS
async function upload(file: File, signed_url: str) {
await axios.put(signed_url, file, {
headers: {
'Content-Type': file.type
},
})
}
Upvotes: 0