Open Connorelsea opened 5 years ago
I am facing the same exact issue. Has anybody found a solution to this?
I think I might've figured it out. Make sure that your stream
is an actual Readable stream. That was my problem at least. Once I created a stream using `var stream = require('stream'), and then passed that stream onto the function, it worked. I followed this SO post to get help with creating a proper stream: https://stackoverflow.com/questions/48534404/create-readstream-from-base64-encoded-string-by-file
Yes, please make sure the stream is a valid Node.js Readable stream.
Thanks for the tip, that helped me identify the issue and fix some other related issues.
For me const { stream, filename, mimetype, encoding } = await file;
only returns { filename: 'profilepic.jpeg' }
, so the stream is null. But I'm not sure why the stream is null but the filename isn't. I am trying to investigate now but may still need help. I will post more info here if I find something out or post what was wrong if I figure it out
On the frontend, using apollo-client, I am attempting to use an upload mutation. I am passing a Blob
object as the file variable. I was able to write this Blob
object to my local filesystem using FileReader
, and it looked visually correct, so I'm unsure what is causing the stream to be undefined on the backend.
Frontend Blob
object:
Frontend mutation code:
const src = gql`
mutation uploadAvatar($file: Upload!) {
uploadAvatar(file: $file) {
filename
}
}
`;
const response = await mutate(src, { file: cropBlob }, apolloClient);
Backend mutation schema:
uploadAvatar(file: Upload!): File!
Will close this issue as this is not a SDK issue, it sounds like a logical error needs your detailed investigation, sorry I cannot give more suggestions about this. Fell free to re-open if you have further questions about SDK.
Which service(blob, file, queue, table) does this issue concern?
blob
Which version of the SDK was used?
@azure/storage-blob ^10.3.0
What's the Node.js/Browser version?
node v9.10.1
What problem was encountered?
Attempting to upload node file stream as blob using
uploadStreamToBlockBlob
and it fails, producing confusing error that I've been unable to pinpoint the cause of.Steps to reproduce the issue?
I created a resolver function for apollo-server 2, where the resolver receives a file stream and then attempts to upload it as a new blob in a container named 'avatars'.
Resolver code
Error code
Have you found a mitigation/solution?
Not yet, reading through the code that it points to now to try to understand what is causing it, but hoping someone here might have an idea of what I'm doing wrong.