Code Monkey home page Code Monkey logo

exploring-browser-based-file-uploads-to-s3's Introduction

I've created this repo to help test and understand the differences between uploading files to S3 as a single file versus multipart file.

Usage

  • Create a new IAM user that only has access to S3

  • Create a new S3 bucket that we can use for testing

  • Configure CORS on the new bucket

      <CORSConfiguration>
          <CORSRule>
              <AllowedOrigin>*</AllowedOrigin>
              <AllowedMethod>HEAD</AllowedMethod>
              <AllowedMethod>GET</AllowedMethod>
              <AllowedMethod>PUT</AllowedMethod>
              <AllowedMethod>POST</AllowedMethod>
              <AllowedMethod>DELETE</AllowedMethod>
              <AllowedHeader>*</AllowedHeader>
              <ExposeHeader>ETag</ExposeHeader>
              <ExposeHeader>x-amz-meta-custom-header</ExposeHeader>
              <MaxAgeSeconds>3000</MaxAgeSeconds>
          </CORSRule>
      </CORSConfiguration>
    
  • Create a file named aws-config.js in javascript and set the following configuration options:

      window.awsAccessKeyId = 'your-iam-user-access-key';
      window.awsSecretAccessKey = 'your-iam-user-secret-key';
      window.awsRegion = 'your-aws-region';
      window.awsS3Bucket = 'your-new-s3-bucket';
    
  • Open s3-upload-test.html in a browser

  • Upload a file and observe the time taken

Potentially useful links

Improvements

I suspect I'll not do anything else on this as I've already spent too much time on it and it was only really designed to test the difference between uploading a single chunk versus multiple chunks. If I do revisit it then here are some things that might be worth working on.

  • Use progress bars to show much of the file has uploaded.

  • Better error handling.

  • Improve the JavaScript - it currently uses lots of global functions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.