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
const uploadAvatar = isAuthenticatedResolver.createResolver(
async (root, args, context, error) => {
const { file } = args;
const { stream, filename, mimetype, encoding } = await file;
const account = "remix2";
const accountKey =
"redacted";
// Use SharedKeyCredential with storage account and account key
const sharedKeyCredential = new SharedKeyCredential(account, accountKey);
// Use sharedKeyCredential, tokenCredential or anonymousCredential to create a pipeline
const pipeline = StorageURL.newPipeline(sharedKeyCredential);
const serviceURL = new ServiceURL(
// When using AnonymousCredential, following url should include a valid SAS or support public access
`https://${account}.blob.core.windows.net`,
pipeline
);
const containerName = "avatars";
const containerURL = ContainerURL.fromServiceURL(serviceURL, containerName);
const blobName = "newblob" + new Date().getTime();
const blobURL = BlobURL.fromContainerURL(containerURL, blobName);
const blockBlobURL = BlockBlobURL.fromBlobURL(blobURL);
const uploadBlobResponse = await uploadStreamToBlockBlob(
Aborter.timeout(30 * 60 * 60 * 1000),
stream,
blockBlobURL,
20
);
console.log(
`Upload block blob ${blobName} successfully`,
uploadBlobResponse
);
}
);
Error code
TypeError: Cannot read property 'on' of undefined
at /Users/connorelsea/Projects/remix-server/node_modules/@azure/storage-blob/dist-esm/lib/utils/BufferScheduler.js:156:40
at new Promise (<anonymous>)
at e.<anonymous> (/Users/connorelsea/Projects/remix-server/node_modules/@azure/storage-blob/dist-esm/lib/utils/BufferScheduler.js:153:25)
at /Users/connorelsea/Projects/remix-server/node_modules/@azure/storage-blob/node_modules/tslib/tslib.es6.js:97:23
at Object.next (/Users/connorelsea/Projects/remix-server/node_modules/@azure/storage-blob/node_modules/tslib/tslib.es6.js:78:53)
at /Users/connorelsea/Projects/remix-server/node_modules/@azure/storage-blob/node_modules/tslib/tslib.es6.js:71:71
at new Promise (<anonymous>)
at __awaiter (/Users/connorelsea/Projects/remix-server/node_modules/@azure/storage-blob/node_modules/tslib/tslib.es6.js:67:12)
at e.do (/Users/connorelsea/Projects/remix-server/node_modules/@azure/storage-blob/dist-esm/lib/utils/BufferScheduler.js:140:14)
at /Users/connorelsea/Projects/remix-server/node_modules/@azure/storage-blob/dist-esm/lib/highlevel.node.js:304:58
at /Users/connorelsea/Projects/remix-server/node_modules/@azure/storage-blob/node_modules/tslib/tslib.es6.js:97:23
at Object.next (/Users/connorelsea/Projects/remix-server/node_modules/@azure/storage-blob/node_modules/tslib/tslib.es6.js:78:53)
at /Users/connorelsea/Projects/remix-server/node_modules/@azure/storage-blob/node_modules/tslib/tslib.es6.js:71:71
at new Promise (<anonymous>)
at __awaiter (/Users/connorelsea/Projects/remix-server/node_modules/@azure/storage-blob/node_modules/tslib/tslib.es6.js:67:12)
at uploadStreamToBlockBlob (/Users/connorelsea/Projects/remix-server/node_modules/@azure/storage-blob/dist-esm/lib/highlevel.node.js:271:9)
at _callee3$ (/Users/connorelsea/Projects/remix-server/resolvers/storage.js:179:38)
at tryCatch (/Users/connorelsea/Projects/remix-server/node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (/Users/connorelsea/Projects/remix-server/node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (/Users/connorelsea/Projects/remix-server/node_modules/regenerator-runtime/runtime.js:117:21)
at step (/Users/connorelsea/Projects/remix-server/resolvers/storage.js:25:191)
at /Users/connorelsea/Projects/remix-server/resolvers/storage.js:25:361
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.
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
uploadStreamToBlockBloband 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.