Azure存储器:在Azure存储器上上传图像成功,但创建了文件夹而不是图像

问题描述 投票:1回答:1

“我的accout的天蓝色存储屏幕截图”我已经将此azure图像用于上传了(C0image)。这已将图像成功上传到Azure存储器上,但是如果我们查看Azure帐户,则会创建一个使用所选图像名称而不是实际图像创建的文件夹。

angular azure blob service

这是负责上传图像的上传功能。请让我知道这里出了什么问题。我将其与角度8一起使用。

这是NPM源代码的upload() { if (this.currentFile !== null) { const baseUrl = this.blob.generateBlobUrl( this.Config, this.currentFile.name ); console.log(baseUrl); this.config = { baseUrl: baseUrl, sasToken: this.Config.sas, blockSize: this.currentFile.size > 1024 * 1024 * 32 ? 1024 * 1024 * 4 : 1024 * 512, // OPTIONAL, default value is 1024 * 32 file: this.currentFile, complete: () => { console.log("Transfer completed !"); }, error: err => { console.log("Error:", err); }, progress: percent => { console.log("Transfer completed =", percent); // this.percent = percent; } }; console.log(this.config); this.blob.upload(this.config); } }

以下是我的配置对象,其中包含SAS令牌详细信息:Github link

javascript angular azure azure-storage-blobs angular8
1个回答
0
投票

我相信问题在于斑点的名称。假设您在其中一项注释中正确复制了Blob名称,那么它将显示为:

Config: UploadParams = {
        sas:
            "https://demo.blob.core.windows.net/?sv=2019-02-02&ss=bfqt&srt=sco&sp=rwdlacup&se=2020-04-13T22:29:27Z&st=2020-04-13T14:29:27Z&spr=https,http&sig=PBJ62e8SU5%2FAef5Npmun5nvzZanb5UbVXqhJ17U1bGE%3D",
        storageAccount: "demo",
        containerName: "demo-images"
    }

[如果您注意到,您的blob名称中有一个斜杠(https://demo.blob.core.windows.net/demo-images/download.jpghttps:/ ),因此,门户网站UI(或与此相关的任何其他Storage Explorer UI)会将其视为虚拟文件夹,因此您将其视为文件夹。

请再次检查您的代码,特别是您如何设置Blob的名称。应该是/

UPDATE

正如我怀疑的那样,您的配置对象中的https://demo.blob.core.windows.net/demo-images/download.jpg参数存在问题。您正在传递SAS URL,而不是SAS令牌。请将sas参数更改为:

sas
© www.soinside.com 2019 - 2024. All rights reserved.