nodejs-docs-samples icon indicating copy to clipboard operation
nodejs-docs-samples copied to clipboard

[@google-cloud/storage] imageFile.download no longer works

Open ollyde opened this issue 1 year ago • 1 comments

"@google-cloud/storage": "^7.7.0",

This code has been working for 4+ years without change. And now all of a sudden it doesn't work.

Very simple example

const imageFile = await storage.bucket(env.gcloudCloudStorage).file(fileUpload.fileLocation);

// Options from the client
const tempLocalPath = `${tmpdir}/${fileId}`;

// Check that the file exists
const exists = await imageFile.exists();
if (!exists[0]) {
  const exists = await imageFile.exists();
  if (!exists[0]) {
    throw returnError('file-not-found-on-cloud', 'File not found');
   }
}

// Create the temp file
// ERROR HERE
// await imageFile.download({ destination: tempLocalPath });

await imageFile.makePublic();
const fileUrl = getFileLink(imageFile);
await downloadFile(fileUrl, tempLocalPath);

The line await imageFile.download({ destination: tempLocalPath }); fails with

TypeError: Cannot read properties of null (reading 'length')
    at getStateLength (/Users/superbadwolf/Projects/my-app/nine_pm_node/node_modules/stream-shift/index.js:16:28)
    at shift (/Users/superbadwolf/Projects/my-app/nine_pm_node/node_modules/stream-shift/index.js:6:99)
    at Duplexify._forward (/Users/superbadwolf/Projects/my-app/nine_pm_node/node_modules/duplexify/index.js:170:35)
    at PassThrough.onreadable (/Users/superbadwolf/Projects/my-app/nine_pm_node/node_modules/duplexify/index.js:136:10)
    at PassThrough.emit (node:events:519:28)
    at emitReadable_ (node:internal/streams/readable:832:12)
    at processTicksAndRejections (node:internal/process/task_queues:81:21)

My resolution for now was making it public and downloading manually, this works..

await imageFile.makePublic();
const fileUrl = getFileLink(imageFile);
await downloadFile(fileUrl, tempLocalPath);

ollyde avatar Dec 21 '23 18:12 ollyde

I'm using .createReadStream() and getting the same error

"@google-cloud/storage": "7.7.0",

Can't event catch it with try/catch or .on('error'... it's crashing whole application.

raaymax avatar Jan 29 '24 11:01 raaymax

@danielduhh for yoru awareness, an issue on storage samples.

iennae avatar May 10 '24 16:05 iennae

@ollyde Apologies in the delay in responding to your issue here.

This issue queue is for handling issues associated with the samples that exist in this repository. This looks like you are reporting an issue with the API potentially or the service itself and sharing your code. I appreciate knowing that there might be some change that was unexpected (are you still experiencing this problem?)

We can't provide assistance on issues that are not associated with samples in this repository. If you have a support contract with Google, please create an issue in the support console.

iennae avatar May 10 '24 17:05 iennae

@iennae I abandoned Google Cloud Platform last year, there are hundreds of bugs & features missing I reported over 2 years, not a single one has been fixed.

And no wonder; when you ignore simple requests like this, it's extremely poor support, I will never be going back, and it seems like Google Cloud is losing customers everyday.

The support console is a joke, never had a reply from it, literally hundreds of tickets.

This is an issue with THIS library, you have marked as completed. Disgraceful.

ollyde avatar May 10 '24 17:05 ollyde