GoogleCloudPlatform / node-red-contrib-google-cloud

Node-RED nodes for Google Cloud Platform
Apache License 2.0
90 stars 57 forks source link

Problem with GCS Write: Type Error, cannot read property "ending" of undefined #5

Closed kolban-google closed 4 years ago

kolban-google commented 5 years ago

The following was posted by user profDgasca:

Hi, I try to create a new jpg file from node-red in a raspi, mi npm version is 6.4.1 my configuration is:

msg = {
filename:'gs://bucket/test.jpg',
payload:msg.payload,
contentType:'image/jpeg'
}

where msg.payload is a buffer

The error is: TypeError: Cannot read property 'ending' of undefined

It's somthing wrong with my config? thanks a lot and regrads

@profDgasca

kolban-google commented 5 years ago

Howdy @profDgasca .... Let's see if we can't pin the puzzle down. First, thanks for evaluating these nodes ... my hope is to be as attentive as possible so keep the comments coming. Where possible, I'd love to see the JSON of failing flows.

Looking at your message description, I want to follow up.

You coded msg.filename as having a value of gs://bucket/test.jpg. Is this exactly what you coded? The reason I ask is that bucket should be the name of your own GCS bucket. For example, if your own GCS bucket were called profdgasca then the value of msg.filename would be:

gs://profdgasca/test.jpg

Can you clarify what you actually coded?

Next I'd like to chat about your value of msg.payload. This will become the content of the GCS object/file. What did you actually code ... because looking at your example you seem to have coded:

msg.payload = msg.payload

which doesn't seem to make much sense. You should set msg.payload to be a string or buffer. If, as I sense, you are writing a JPEG file, then I am thinking that msg.payload should contain a JavaScript Buffer object containing the binary data of the JPEG file.

Please review these thoughts and post back. If something isn't clear here, don't hesitate to ask for clarification.

kolban-google commented 4 years ago

Closing due to staleness