瀏覽器圖片直傳AWS S3

都2016年了,從browser上傳個圖片到S3還這麼折騰...真想罵聲暗
折騰原因:

  • s3 bucket: cors
  • s3 credentials
    • upload to s3 from server
    • upload to s3 from browser
    • cognito/IAM
      • ajax: signature from backend
      • aws-sdk

前端

resize原圖或縮圖都要利用canvas產生縮圖,image再轉成blob (類似檔案的物件),而後才能上傳

aws

https://github.com/aws/aws-sdk-js
以下必讀:

Screen Shot 2016-11-16 at 11.57.17 PM.png

https://github.com/minio/minio-js
http://blog.tcs.de/post-file-to-s3-using-node/
https://blog.fineuploader.com/2013/08/16/fine-uploader-s3-upload-directly-to-amazon-s3-from-your-browser/#what-is-this
https://github.com/SwingDev/s3-browser-direct-upload

cognito/IAM

image resize:
https://github.com/rossturner/HTML5-ImageUploader
http://stackoverflow.com/questions/23945494/use-html5-to-resize-an-image-before-upload
https://hacks.mozilla.org/2011/01/how-to-develop-a-html5-image-uploader/
https://github.com/nodeca/pica

canvas to blob
http://stackoverflow.com/questions/4998908/convert-data-uri-to-file-then-append-to-formdata
http://stackoverflow.com/questions/13990673/upload-canvas-data-to-s3
https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob
http://stackoverflow.com/questions/19032406/convert-html5-canvas-into-file-to-be-uploaded

aws s3 debug tool
http://s3.amazonaws.com/doc/s3-example-code/post/post_sample.html

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 15,567评论 2 45
  • 每个女孩年轻时最美的梦大概都是关于天长地久的爱情,你是不是也一样? 她是我众多女生朋友中的一位,身材瘦小、长相普通...
    孙大年阅读 337评论 2 2
  • 关于远方,大概是有一天能说走就走的旅行,能一个人上路,看不同的风景、遇见不一样的人,由陌生到熟悉,山一程水一程,在...
    从此风凉便入梦阅读 197评论 0 0
  • 交卷,100分!我今天终于把驾照考过了。说到考驾照,回想起来,可谓一把辛酸泪。科一科三科四都是一次过,可是科二挂了...
    一只小财喵阅读 305评论 5 2