Name of Azure blob/filename when uploading

我只是一个虾纸丫 提交于 2019-12-24 12:33:58

问题


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'
       }

    });

回答1:


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"
},



回答2:


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"); 
  }); 
}



回答3:


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;
    }
}


来源:https://stackoverflow.com/questions/22247244/name-of-azure-blob-filename-when-uploading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!