TypeError: scheduler.do is not a function using blob.uploadStream
TypeError: scheduler.do is not a function using blob.uploadStream
二手Package
我正在尝试使用
将 blob 上传到 azure blob 存储
blockBlobClient.uploadStream()
但是,程序包抛出此错误:
TypeError: scheduler.do is not a function
at BlockBlobClient.uploadStream (Clients.js:1954)
我的代码是:
const blockBlobClient = sourceClient.getBlockBlobClient(blobName);
const blockSize = 4 * 1024 * 1024; // the block size in the uploaded block blob
const uploadBlobResponse = await blockBlobClient.uploadStream(file, blockSize, 20, {onProgress: (ev) => console.log(ev)});
我该如何解决这个错误?
您收到此错误的原因是您从浏览器调用 uploadStream
方法,但它仅在 Node.JS 运行时可用。来自代码注释 here
:
/**
* ONLY AVAILABLE IN NODE.JS RUNTIME.
*
* Uploads a Node.js Readable stream into block blob.
*
* PERFORMANCE IMPROVEMENT TIPS:
* * Input stream highWaterMark is better to set a same value with bufferSize
* parameter, which will avoid Buffer.concat() operations.
*
* @param stream - Node.js Readable stream
* @param bufferSize - Size of every buffer allocated, also the block size in the uploaded block blob. Default value is 8MB
* @param maxConcurrency - Max concurrency indicates the max number of buffers that can be allocated,
* positive correlation with max uploading concurrency. Default value is 5
* @param options - Options to Upload Stream to Block Blob operation.
* @returns Response data for the Blob Upload operation.
*/
public async uploadStream(
当您在基于浏览器的应用程序中使用此 SDK 时,您希望使用的上传方法是 uploadBrowserData
or uploadData
。
二手Package
我正在尝试使用
将 blob 上传到 azure blob 存储blockBlobClient.uploadStream()
但是,程序包抛出此错误:
TypeError: scheduler.do is not a function
at BlockBlobClient.uploadStream (Clients.js:1954)
我的代码是:
const blockBlobClient = sourceClient.getBlockBlobClient(blobName);
const blockSize = 4 * 1024 * 1024; // the block size in the uploaded block blob
const uploadBlobResponse = await blockBlobClient.uploadStream(file, blockSize, 20, {onProgress: (ev) => console.log(ev)});
我该如何解决这个错误?
您收到此错误的原因是您从浏览器调用 uploadStream
方法,但它仅在 Node.JS 运行时可用。来自代码注释 here
:
/**
* ONLY AVAILABLE IN NODE.JS RUNTIME.
*
* Uploads a Node.js Readable stream into block blob.
*
* PERFORMANCE IMPROVEMENT TIPS:
* * Input stream highWaterMark is better to set a same value with bufferSize
* parameter, which will avoid Buffer.concat() operations.
*
* @param stream - Node.js Readable stream
* @param bufferSize - Size of every buffer allocated, also the block size in the uploaded block blob. Default value is 8MB
* @param maxConcurrency - Max concurrency indicates the max number of buffers that can be allocated,
* positive correlation with max uploading concurrency. Default value is 5
* @param options - Options to Upload Stream to Block Blob operation.
* @returns Response data for the Blob Upload operation.
*/
public async uploadStream(
当您在基于浏览器的应用程序中使用此 SDK 时,您希望使用的上传方法是 uploadBrowserData
or uploadData
。