3

有谁知道是否可以使用 Fine Uploader 上传到 S3 存储桶内的文件夹?我尝试向请求端点添加一个 '\foldername' 但没有运气。

谢谢。

4

4 回答 4

7

S3 doesn't have folders. Some UIs (such as the one in the AWS console) and higher-level APIs may provide this concept, as an abstraction, but S3 doesn't have any native understanding of folders, only keys. You can create any key you want and pass it along to Fine Uploader S3, it will store that file given that specific key. For example, "folder1/subfolder/foobar.txt" is a perfectly valid key name. By default, Fine Uploader generates a UUID and uses that as your object's key name, but you can easily change this by providing an objectProperties.key value, which can also be a function. See the S3 objectProperties option in the documentation for more details.

于 2013-11-23T18:50:54.780 回答
5

这对我有用:

var uploader = new qq.s3.FineUploader({
    // ...
    objectProperties: {
        key: function(fileId) {
            return 'folder/within/bucket/' + this.getUuid(fileId);
        }
    }
});
于 2016-12-07T04:01:48.200 回答
3
$("#fineuploader-s3").fineUploaderS3({
    // ....
    objectProperties: {
        key: function (fileId) {

            var filename = $('#fineuploader-s3').fineUploader('getName', fileId);
            var uuid = $('#fineuploader-s3').fineUploader('getUuid', fileId);
            var ext = filename.substr(filename.lastIndexOf('.') + 1); 

           return  'folder/within/bucket/' + uuid + '.' + ext;
        }
    }
});
于 2015-02-17T16:18:58.997 回答
0

您可以在上传到服务器之前修改路径:

uploader.on('submit', (id) => {   
  const key = s3Uploader.methods.getUuid(id)   
  const newkey = 'folder/within/bucket/' + key   
  uploader.methods.setUuid(id, newkey) 
})
于 2017-12-02T09:10:20.710 回答