Repository navigation
Closed
Labels
api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
For example I uploaded Labs.all.screens.pdf into my backet 'aifiles'.
I get a link to the file as follows (coffescript)
fileOptions =
action: 'read',
expires: '01-01-2100'
destination = path + '/' + fileName
file = bucket.file destination
uploadStream = file.createWriteStream();
....
uploadStream.on 'finish', ->
file.getSignedUrl fileOptions, (err, url) =>
return done err if err
done null, url
But after moving the file as follows (coffescript):
move: (filePath, newFilePath, done) ->
file = bucket.file filePath
file.move newFilePath, (err, destinationFile, apiResponse) ->
if err
done err
else
destinationFile.getSignedUrl fileOptions, (err, url) =>
return done err if err
done null, url, apiResponse
new file link doesn't work for me:
<Code>SignatureDoesNotMatch</Code>
<Message>
The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method.
</Message>
<StringToSign>
GET 4102444800 /aifiles/uploads%2Fapps%2Facme_theme_park%2F9a52117f-0254-4967-b97f-569fbfb0542b%2FLabs.pdf
</StringToSign>
</Error>
Now I tryed upload other file once again and in this time I have a problem with first link
<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>
The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method.
</Message>
<StringToSign>
GET 4102444800 /aifiles/uploads%2Fapps%2Facme_theme_park%2Fbf95eb77-9531-4c5c-914f-db4f32819c3b%2Fcomment.svg
</StringToSign>
</Error>
Full code:
path = require 'path'
conf = require 'nconf'
gcloud = require 'gcloud'
gcs = gcloud.storage
projectId: conf.get 'GOOGLE_PROJECT_ID'
keyFilename: path.resolve process.cwd(), conf.get 'GOOGLE_PRIVATE_JSON_KEY'
bucket = gcs.bucket conf.get 'GOOGLE_BUCKET'
fileOptions =
action: 'read',
expires: '01-01-2100'
module.exports =
uploadStream: (fileStream, path, fileName, done) ->
destination = path + '/' + fileName
file = bucket.file destination
uploadStream = file.createWriteStream();
fileStream.on 'error', (err) ->
done err
uploadStream.on 'error', (err) ->
done err
uploadStream.on 'finish', ->
file.getSignedUrl fileOptions, (err, url) =>
return done err if err
done null, url
fileStream.pipe uploadStream
move: (filePath, newFilePath, done) ->
file = bucket.file filePath
file.move newFilePath, (err, destinationFile, apiResponse) ->
if err
done err
else
destinationFile.getSignedUrl fileOptions, (err, url) =>
return done err if err
done null, url, apiResponse
Metadata
Metadata
Assignees
Labels
api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Activity
stephenplusplus commentedon Dec 8, 2015
Thanks for reporting this! I was able to reproduce this. It doesn't look like our code is doing anything wrong in this situation. I wonder if this is an upstream issue? @jgeewax
stephenplusplus commentedon Dec 8, 2015
Also, here is the example converted to JS for us non-:coffee: folk :) https://gist.github.com/stephenplusplus/5bf537da70df0c9db36c
jgeewax commentedon Dec 8, 2015
I'm having a bit of trouble following, are you saying:
?
stephenplusplus commentedon Dec 8, 2015
Yep, and the signed url works when it's done before the move (move = copy to new file and delete original).
DeWenS commentedon Dec 9, 2015
Found solution
var fileOptions = { action: 'read', expires: '01-01-2100' };should be inside uploadStream and move functions, because getSignedUrl added "recource" prop to this object, which causes error
jgeewax commentedon Dec 9, 2015
That sounds about right. If we're modifying the
fileOptionsobject, those changes would be sticky and carry over to the next call, right?jgeewax commentedon Dec 9, 2015
Can we maybe operate on a copy of the configuration ...?
stephenplusplus commentedon Dec 9, 2015
Good catch, sorry I missed that.
jgeewax commentedon Dec 9, 2015
I'm actually going to re-open this for @stephenplusplus to look at today :)
chore(deps): update dependency jsdoc to v4 (#1009)
feat: add type parameter to warn function (#1009)
fix: bring back LRO mixin (#1009)
fix: bring back LRO mixin (#1009)
fix: bring back LRO mixin (#1009)
docs: add tailEntries sample and docs (#1009)