filepicker urls with s3

淺唱寂寞╮ 提交于 2019-12-24 10:59:00

问题


I'm looking to build a photo management app and I've decided to use Filepicker.io with Amazon s3 to manage the uploads/hosting of static files. I plan on having Filepicker handle the upload of images to s3, and then I will store the url of the image in a database -- these urls will be embedded in a template. For example,

HTML:

<input type="file" name="datafile">
  {{#if src}}
  <img src='{{src}}'>
  {{/if}}

Javascript :

'change input' : function (e, t) {

      var file = e.currentTarget.files[0];
      if (file) {
        filepicker.store(file, function(fp){
          // Set URL to fpURL 
        }, function(err){
          console.log('error', err);
        }, function(progress){
          console.log('loading', progress);
        });
      }

    }

My question: Is it better to store the filepicker url in the database? Or should I be saving the key url, which can link directly to s3?

My filePicker success object looks like this:

{url: "https://www.filepicker.io/api/file/wppeyWAUQaaX0HPgXQ", 
size: 76511, type: "image/png", 
key: "EdqmSpbDQziIvSfI4g_logo.png", 
filename: "logo.png"}

回答1:


We recommend storing the URL directly, as that way you can take advantage of the conversion features and other functionality we provide on top of the URLs. Plus, you don't have to mess with the S3 APIs directly and can perform GETs and POSTs on the url instead



来源:https://stackoverflow.com/questions/13315655/filepicker-urls-with-s3

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