oittaa / gcp-storage-emulator

Local emulator for Google Cloud Storage
BSD 3-Clause "New" or "Revised" License
155 stars 42 forks source link

Support for streaming of files upload #258

Open MarcDanjou opened 8 months ago

MarcDanjou commented 8 months ago

Hello there, thanks for this awesome package. I am currently using it in a docker-compose env + a nodejs fastify application running on node 20.

I am trying to stream a file upload to a bucket, following the samples from google there ==> https://github.com/googleapis/nodejs-storage/blob/main/samples/streamFileUpload.js

  // Creates a client
  const storage = new Storage();

  // Get a reference to the bucket
  const myBucket = storage.bucket(bucketName);

  // Create a reference to a file object
  const file = myBucket.file(destFileName);

  // Create a pass through stream from a string
  const passthroughStream = new stream.PassThrough();
  passthroughStream.write(contents);
  passthroughStream.end();

  async function streamFileUpload() {
    passthroughStream.pipe(file.createWriteStream()).on('finish', () => {
      // The file upload is complete
    });

    console.log(`${destFileName} uploaded to ${bucketName}`);
  }

  streamFileUpload().catch(console.error);

But at every call, I am receiving this error ==> 'NoneType' object is not callable

image

I did the same test using a real bucket on Google cloud storage and it works flawlessly, I guess this is related to some methods not implemented yet in this emulator nope ?

Thanks again :+1:

System-Glitch commented 3 months ago

Same issue here. I tried with the following cURL request:

curl --location 'http://localhost:9023/storage/v1/b/test-bucket/o?uploadType=multipart' \
--header 'Content-Type: multipart/related; boundary=separator_string' \
--data '--separator_string
Content-Type: application/json; charset=UTF-8

{"name":"my-document.txt"}

--separator_string
Content-Type: text/plain

This is a text file.
--separator_string--'

I was using this documentation as a reference.