Name of Azure blob/filename when uploading

2019-08-13 11:35发布

When I upload to azure container the filename that is saved is the uuid(guid) how can I change that?

I create the signatur by using the querystring "bloburi" added in the signature request.

 $("#fine-uploader").fineUploaderAzure({
        autoUpload : true,
        debug: true,
        validation: {
            itemLimit: 10,
            sizeLimit: 209715200 // 200 mb
        },
        resume: {
            enabled: true,
            id: 'ResumeUpload',
            cookiesExpireIn: 7
        },
        extraButtons: {
            folders: true
        },
        deleteFile: {
            enabled: true
        },
        request: {                
            endpoint: 'https://xxx.blob.core.windows.net/'
        },
        cors: {
            //all requests are expected to be cross-domain requests
            expected: true,

            //if you want cookies to be sent along with the request
            sendCredentials: true
        },
        signature: {
            endpoint: '/sig/'
        },
       uploadSuccess: {
           endpoint: '/success'
       }

    });

3条回答
小情绪 Triste *
2楼-- · 2019-08-13 11:54

The default value for the name option is 'uuid' which will set the filename in Azure to the uuid. You can instead set it to 'filename' to have the object stored under the filename, or provide a function that will create some other name.

blobProperties: {
    name: 'filename'
}

From my experience, the best method for generating filenames is to save the filename under a unique id subfolder. This guarantees that you save the original filename, and that there are no naming collisions.

blobProperties: {
    name: function(id) {
        var uuid = this.getUuid(id),
            filename = this.getName(id);

        return uuid + '/' + filename;
    }
}
查看更多
小情绪 Triste *
3楼-- · 2019-08-13 12:01

The docs are wrong. For version 4.4.0 the correct property to set is:blobProperties

// 'uuid', 'filename', or a function which may be promissory
blobProperties: {
    name: "uuid"
},
查看更多
我欲成王,谁敢阻挡
4楼-- · 2019-08-13 12:16

I know this is an old question, but I ran into the same problem. You'll need to pass a Promise to get it to work:

name: function (id) { 
  return new Promise(function (resolve) {   
    resolve("The String You Want to Pass"); 
  }); 
}
查看更多
登录 后发表回答