【发布时间】:2022-11-17 06:35:33
【问题描述】:
我正在使用 Vue.js 构建电子应用程序。我希望我的用户下载和上传文件,这些文件保存在 Azure Blob 中。
我已经成功地进行了下载,但我在上传时遇到了问题。我在我的 Vue 组件中使用以下代码:
import { BlobServiceClient } from '@azure/storage-blob'
const blobServiceClient = BlobServiceClient.fromConnectionString('connString')
const containerClient = blobServiceClient.getContainerClient('my container name')
const blockBlobClient = await this.containerClient.getBlockBlobClient('name of my blob')
const uploadBlobResponse = await blockBlobClient.uploadFile('C://dev//animage.jpg')
我得到的错误是“TypeError: Cannot read property 'size' of undefined'”,它源自 uploadFile 方法:
似乎 fsStat 无法解析我提供的文件路径。
我尝试过不同的路径,也尝试过 path.parse() 但没有任何运气。有谁知道我在这里做错了什么?
【问题讨论】:
-
这看起来不像是有效的 Windows 路径。您是否尝试过使用反斜杠(并且只有一个斜杠),例如
C:\dev\animage.jpg?另外 - 仅供参考 - 您应该只对代码/数据/错误/等内容使用格式化文本。原因见Please do not upload images of code/data/errors.
标签: javascript azure azure-blob-storage