GeezerVison is showing github.com — Storage File.download error · Issue #494 · googleapis/google-cloud-node
Storage File.download error #494Labels 🚨This issue needs some love.api: storageIssues related to the Cloud Storage API.triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. DescriptionI think there is an error in this function (storage/file.js):
File.prototype.download = function(options, callback) {
if (util.is(options, 'function')) {
callback = options;
options = {};
}
callback = once(callback);
var destination = options.destination;
delete options.destination;
var fileStream = this.createReadStream(options);
if (destination) {
fileStream
.on('error', callback)
.pipe(fs.createWriteStream(destination))
.on('error', callback)
.on('finish', callback);
} else {
var fileContents = new Buffer('');
fileStream
.on('error', callback)
.on('data', function(chunk) {
fileContents = Buffer.concat([fileContents, chunk]);
})
.on('complete', function() {
callback(null, fileContents);
});
}
};
I dont use the destination option, and the function works, but if I have multiple requests to the same file. Then somtimes the download is pending and never returns anything...
I don't know if it is the once(callback) because it is the same callback for multiple requests but this is strange, I replaced the function with my own code and now it is working:
var iStream = file.gFile.createReadStream();
var fileData = new Buffer('');
iStream.on('error', function(err){
Log.error(err);
loadCB(null);
});
iStream.on('data', function(data){
fileData = Buffer.concat([fileData, data]);
});
iStream.on('complete', function() {
loadCB(fileData);
});
Activitystephenplusplus commented on Apr 13, 2015 Thanks for looking into this! Can you demonstrate how you are making multiple requests? Marc477 commented on Apr 13, 2015 I'm hosting videos on google storage, I use a xml file to retreive the info of the video but I have to edit it server side before sending it to the client (so I use .download to get the xml file from storage to compute engine). If I start 7-8 pages at the same time in my browser, then they all try to get the xml file but some of them will never get a response (pending....) and no errors are thrown server side.
With the second code below I don't get this error callmehiphop commented on Jul 28, 2015 @Marc477 Are you still experiencing this issue? If so, could you provide code snippets on how you were using File#download (options, etc.)?
once doesn't augment the actual function, so you should be able to re-use the same callback as many times as you like.
stephenplusplus commented on Aug 24, 2015 We've made multiple changes to some core aspects of our library since this issue was opened. Without more details, it's hard for us to debug. I hope it's been resolved since you opened this issue @Marc477, but if not, please re-open with anything else you can share that will help us catch the bug.
MetadataMetadata🚨This issue needs some love.api: storageIssues related to the Cloud Storage API.triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. DevelopmentNo branches or pull requestsIssue actions
|