All Projects → sbolel → ionic-image-upload

sbolel / ionic-image-upload

Licence: MIT license
Ionic Plugin for Uploading Images to Amazon S3

Programming Languages

CSS
56736 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to ionic-image-upload

image-uploader
JavaScript Image Uploader Library for use with Amazon S3
Stars: ✭ 19 (-26.92%)
Mutual labels:  ionic, aws-s3, s3-bucket, s3-storage, image-upload, image-uploader
0x4447 product s3 email
📫 A serverless email server on AWS using S3 and SES
Stars: ✭ 2,905 (+11073.08%)
Mutual labels:  aws-s3, s3, s3-bucket
Sbt S3 Resolver
☁️Amazon S3-based resolver for sbt
Stars: ✭ 112 (+330.77%)
Mutual labels:  aws-s3, s3, s3-bucket
Json2typescript
Convert JSON to TypeScript with secure type checking!
Stars: ✭ 230 (+784.62%)
Mutual labels:  ionic, npm-package, ionic-framework
flask-drive
A simple Flask app to upload and download files off Amazon's S3
Stars: ✭ 23 (-11.54%)
Mutual labels:  aws-s3, s3, s3-bucket
Minio Hs
MinIO Client SDK for Haskell
Stars: ✭ 39 (+50%)
Mutual labels:  aws-s3, s3, s3-bucket
Mobiscroll
Cross platform UI controls for progressive web and hybrid apps (plain JS, jQuery, Angular and React)
Stars: ✭ 1,510 (+5707.69%)
Mutual labels:  ionic, javascript-library, ionic-plugin
Cloudexplorer
Cloud Explorer
Stars: ✭ 170 (+553.85%)
Mutual labels:  s3, s3-bucket, s3-storage
terraform-aws-s3
Terraform module to create default S3 bucket with logging and encryption type specific features.
Stars: ✭ 22 (-15.38%)
Mutual labels:  s3, s3-bucket, s3-storage
ionic-login-component
Free sample of Premium Ionic Login Component
Stars: ✭ 17 (-34.62%)
Mutual labels:  ionic, ionic-framework, ionic-plugin
s3cli
Command line tool for S3
Stars: ✭ 21 (-19.23%)
Mutual labels:  aws-s3, s3, s3-storage
Goofys
a high-performance, POSIX-ish Amazon S3 file system written in Go
Stars: ✭ 3,932 (+15023.08%)
Mutual labels:  aws-s3, s3, s3-bucket
Aws.s3
Amazon Simple Storage Service (S3) API Client
Stars: ✭ 302 (+1061.54%)
Mutual labels:  aws-s3, s3, s3-storage
Bucket-Flaws
Bucket Flaws ( S3 Bucket Mass Scanner ): A Simple Lightweight Script to Check for Common S3 Bucket Misconfigurations
Stars: ✭ 43 (+65.38%)
Mutual labels:  aws-s3, s3, s3-bucket
simply-static-deploy
WordPress plugin to deploy static sites easily to an AWS S3 bucket.
Stars: ✭ 48 (+84.62%)
Mutual labels:  aws-s3, s3, s3-bucket
Node S3 Uploader
Flexible and efficient resize, rename, and upload images to Amazon S3 disk storage. Uses the official AWS Node SDK for transfer, and ImageMagick for image processing. Support for multiple image versions targets.
Stars: ✭ 237 (+811.54%)
Mutual labels:  aws-s3, s3, npm-package
awesome-storage
A curated list of storage open source tools. Backups, redundancy, sharing, distribution, encryption, etc.
Stars: ✭ 324 (+1146.15%)
Mutual labels:  s3, s3-bucket, s3-storage
ionic-hockeyapp
Need HockeyApp in your Ionic application, add this package!
Stars: ✭ 19 (-26.92%)
Mutual labels:  ionic, ionic-framework, ionic-plugin
BlobHelper
BlobHelper is a common, consistent storage interface for Microsoft Azure, Amazon S3, Komodo, Kvpbase, and local filesystem written in C#.
Stars: ✭ 23 (-11.54%)
Mutual labels:  aws-s3, s3, s3-bucket
jsdoc-api
A programmatic interface for jsdoc3 with a few extra features
Stars: ✭ 55 (+111.54%)
Mutual labels:  npm-package, javascript-library

Ionic Image Upload

circle-ci js-standard

An Ionic Starter App that demonstrates using the image-uploader open source plugin for uploading image files to an S3 bucket.

Getting Started

Install image-uploader via Bower:

bower install --save s3-image-uploader

Include image-upload.bundle.min.js in your app:

<script src="lib/s3-image-uploader/dist/image-uploader.min.js"></script>

Or, with the Amazon SDK included:

<script src="lib/s3-image-uploader/dist/image-uploader.bundle.min.js"></script>

Upload an image from a controller

.controller('UploadController', function ($scope){
  var imageUploader = new ImageUploader()
  $scope.file = {}
  $scope.upload = function() {
    imageUploader.push($scope.file, function(data){
      console.log('File uploaded Successfully', $scope.file, data)
      $scope.uploadUri = data.url
      $scope.$digest()
    })
  }
})

Full Example

File upload form HTML:

<ion-content ng-controller="UploadController">
  <input class="bottom-marg-15" type="file" name="file" file="file">
  <button class="button button-small button-full button-positive" ng-disabled="file.size&amp&ampfalse || uploadProgress&gt0" ng-click="upload()" ng-cloak="">Upload</button>
  <img class="fit" ng-if="uploadUri" ng-src="{{uploadUri}}">
  <a ng-href="{{uploadUri}}" ng-bind="uploadUri"></a>
</ion-content>

file Directive:

.directive('file', function() {
  return {
    restrict: 'AE',
    scope: {
      file: '@'
    },
    link: function(scope, el, attrs){
      el.bind('change', function(event){
        var files = event.target.files
        var file = files[0]
        if(file.size>0){
          scope.file = file
          scope.$parent.file = file
        } else {
          scope.file = {}
          scope.$parent.file = {} 
        }
        scope.$apply()
      })
    }
  }
})

Configuring AWS S3

You are welcome to use the public S3 bucket that is preconfigured in src/image-upload.js. This public bucket will only accept files with JPG and PNG extensions up to 10MB in size. The files are automatically deleted after 24 hours.

To use your own Amazon S3 bucket, change the information in src/image-upload.js and uglify by running grunt in Terminal from the project directory.

Setting up an AWS S3 Bucket for use with Ionic Image Upload

Below is a summary of Uploading To S3 With AngularJS by Cheyne Wallace

To setup an S3 bucket for use with the Ionic Image Upload plugin, we need to:

  • Configure an AWS S3 bucket by creating a "public" IAM account:
    • The IAM user will only have permission to PUT files into a particular AWS Bucket and nothing else.
    • This users API key will be public -- anyone will be able to upload to your bucket if they use this key.
  • Configure the bucket to expire all objects within 24 hours.
    • Even if someone uploads a 10 Gigabyte file, it will eventually be deleted.
  • Configure CORS to prevent uploading of content from anywhere other than your own domain.
  • Create a server to transfer uploaded files from the temporary bucket to a permanent bucket:
    • When a new file is uploaded to this temporary bucket from the app
    • App will send the details of the file to the server
    • Server will perform any necessary transformations, encryption, resizing, or processing, and,
    • Server will move the file into a permanent bucket.

1. Create the IAM User

  1. Open AWS console to the "Security Credentials" section.
  2. Create a new user and call it something like "app_public".
  3. Make sure you download the key information when it is presented, this is what we’ll be feeding into our app later to upload with.
  4. Under the permissions section, click "attach a new policy", then select the policy generator.
  5. Select Amazon S3 as the service and only select the PutObject action from the drop down list.
  6. The ARN is an Amazon Resource Name. This will look like arn:aws:s3:::your_bucket_name
  7. Click "add statement", then save and apply policy.

Now your user has write-only access to the bucket.

Your policy is going to look something like this:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stmt126637111000",
      "Effect": "Allow",
      "Action": [
        "s3:PutObject"
      ],
      "Resource": [
        "arn:aws:s3:::your_bucket_name"
      ]
    }
  ]
}

2. Configure CORS And Expiry On The Bucket

Go to the AWS S3 console, click your bucket, then click the Properties button. You'll use the "Add CORS Configuration" button to configure your bucket to only allow PUT requests from particular origins.

You can use the following sample config -- edit to reflect your development, production and staging environments.

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <CORSRule>
        <AllowedOrigin>http://localhost:3000</AllowedOrigin>
        <AllowedOrigin>https://www.yourdomain.com</AllowedOrigin>
        <AllowedOrigin>http://staging.yourdomain.com</AllowedOrigin>
        <AllowedMethod>PUT</AllowedMethod>
        <MaxAgeSeconds>3000</MaxAgeSeconds>
        <ExposeHeader>x-amz-server-side-encryption</ExposeHeader>
        <ExposeHeader>x-amz-request-id</ExposeHeader>
        <ExposeHeader>x-amz-id-2</ExposeHeader>
        <AllowedHeader>*</AllowedHeader>
    </CORSRule>
</CORSConfiguration>

Expire the objects in this bucket after some short period to prevent malicious use. Your server side code should handle moving and deleting valid files so you can assume those that are left after 24 hours are not meant to be there.

  1. From your S3 console, view a bucket, and then click Properties.
  2. Expand the "Lifecycle Rules" section and follow the prompts.
  3. Set the action to "Permanently Delete Only" and set it for 1 day -- this will delete any objects in the bucket that are older than 1 day permanently.

Now, you're ready to use this bucket in your Ionic Image Upload app!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].