0

if I want to modify the filename on S3 storage, first i need to call the filepicker.pick then filepicker.store . File is then uploaded but filename is not changed as I have specify in store function. Any idea why this is not done?

   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 Answers2

0

What is blob.key.split('_')[1] returning? Filename needs to be in single quotes per Filestack documentation: https://www.filestack.com/docs/file-ingestion/javascript-api/store

{filename: 'MyCoolPhoto.png'}

sjmrt
  • 16
  • 1
  • I traced down the option parameter , filename is double quoted: ` {location: "S3", path: "/", container: "bepisupportdocs.bepi-intl.org", filename: "OZ.pdf"} ` As the file is uploaded in the given location , i think double quote will work . But filename appears as '_OZ.pdf' and not like 'OZ.pdf' . – kurumlu Aug 08 '16 at 10:55
0

OK I have figured out. Filename should be integrated in path field of options and not in a seperate field. Code should be like below :

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