成功获取filepicker.io后,s3文件名不会更改

时间:2016-08-04 11:08:24

标签: amazon-s3 filepicker.io filepicker

如果我想修改S3存储上的文件名,首先我需要调用filepicker.pick然后调用filepicker.store。然后上传文件但不更改文件名,因为我已在商店功能中指定。知道为什么不这样做吗?

   filepicker.pick
     maxfiles: 1
     maxSize: 20*1024*1024
     mimetypes: ['image/*','document/*','text/*','application/pdf']
     language: Translation.language()
     services: ["COMPUTER","DROPBOX","URL","EVERNOTE","GOOGLE_DRIVE","SKYDRIVE"]
  , (blob) ->
     $(t.$('.filename')).val(blob.filename)
     $(t.$('.awskey')).val(blob.key)
     oldBlob=blob
     filepicker.store blob,
        location: 'S3'
        path: "/"
        container: 'bepisupportdocs.bepi-intl.org'
        filename:blob.key.split('_')[1],
        (new_blob) ->
           filepicker.remove oldBlob
           console.log JSON.stringify new_blob if debugThis
  , Fp.uploadError 

2 个答案:

答案 0 :(得分:0)

什么是blob.key.split('_')[1]返回?每个Filestack文档需要使用单引号文件名:https://www.filestack.com/docs/file-ingestion/javascript-api/store

{filename:'MyCoolPhoto.png'}

答案 1 :(得分:0)

好的,我已经想通了。文件名应该集成在选项的路径字段中,而不是在单独的字段中。代码应如下所示:

filepicker.pick
 maxfiles: 1
 maxSize: 20*1024*1024
 mimetypes: ['image/*','document/*','text/*','application/pdf']
 language: Translation.language()
 services: ["COMPUTER","DROPBOX","URL","EVERNOTE","GOOGLE_DRIVE","SKYDRIVE"]
 , (blob) ->
 $(t.$('.filename')).val(blob.filename)
 $(t.$('.awskey')).val(blob.key)
 oldBlob=blob
 filepicker.store blob,
    location: 'S3'
    path: "/"+blob.filename
    container: 'bepisupportdocs.bepi-intl.org',
    (new_blob) ->
       filepicker.remove oldBlob
       console.log JSON.stringify new_blob if debugThis

,Fp.uploadError