My Cloud Storage signed download URLs fail after three days. I think I've fixed the problem, so this question might be a solution to others. Ask me in three days whether this solution worked!
Here's the complete error message:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
SignatureDoesNotMatch
The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method.
GET 1742169600 /languagetwo-cd94d.appspot.com/Audio%2FSpanish%2FLatin_America-Sofia-Female-IBM%2Fagua.mp3
I googled the error message and saw some discussions that the problem is with Content-Type. I don't specify Content-Type in my code when I upload the files to Storage. When I set contentType in the code when uploading the download URLs fail immediately, with the same error message. That suggests that I'm on the right track.
file.getSignedUrl({
action: 'read',
expires: '03-17-2025',
contentType: 'audio/mp3'
})
The expiration date in the download URLs is March 17, 2025, so that's not the problem.
Google's documentation on Signed URLs says that the syntax is Content_Type. The IETF documentation on content-type says that the syntax is Content-Type. I tried
file.getSignedUrl({
action: 'read',
expires: '03-17-2025',
content_type: 'audio/mp3'
})
and my files download and play. I don't want to wait three days to see if they continue to work, so please let me know if there's something else I need to fix!
Just for grins I tried
file.getSignedUrl({
action: 'read',
expires: '03-17-2025',
content-type: 'audio/mp3'
})
and firebase deploy wouldn't accept the code. The hyphen isn't allowed in keys.
Google's documentation on Signed URLs says
As needed. If you provide a content-type, the client (browser) must provide this HTTP header set to the same value.
As needed isn't the same as Optional.
My .mp3 files and my .webm download URLs are failing, so it doesn't matter what the content of the files are.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)