Skip to content

tzmartin/Ti-Amazon-S3

Repository files navigation

Ti Amazon S3

A CommonJS module for Amazon S3.

Module location: /blob/master/app/assets/modules/ti.amazon.s3.js

This is a mobile app test case, built using Appcelerator Alloy / Titanium Mobile SDK.

Version: v1.1
Tested: Titanium SDK v5.3.1.GA

test

Watch the Vimeo link

Description

Upload media files directly to an Amazon S3 bucket using signed URLs and Amazon's REST API. This app contains a JavaScript module that simplifies the authorization flow and makes is EASY PEASY LEMON SQUEEZY!

Example Apps

App Publisher Description
Whichiscooler Whichiscooler S. Marston Maddox Whichiscooler is a tool to discover and share the coolest things.

|

Add your app

How to Use

Alloy.Globals.AWS = require('modules/ti.amazon.s3');

Alloy.Globals.AWS.PUT({
	key: 'YOUR KEY',
	secret: 'YOUR SECRET',
	bucket: 'YOUR BUCKET',
	GSM:' -0700',
	debug:true,
	fileName: FILE_TO_UPLOAD,
	uploadDir: 'PATH_TO_UPLOAD_DIR_ON_S3',
	timeout: 99000,
	onsendstream: function(e) {},
	error: function(e) {},
	success: function(e) {
		Ti.API.info('DONE!!')
	}
});

Note: This is a complete rewrite. If you used this project in the past, delete the old one and import this one.

A single module file lives in the app/assets/modules/ directory.

Assets folder

Alternatively

You can compile this JavaScript file into a native module and ship it as a static binary. If you're interested, download this zip file ti.amazon.s3-iphone-1.1.0.zip and add it to your tiapp.xml.

Instatiate it using require('ti.amazon.s3');.

Requirements

Amazon Configuration

Obtain S3 credentials and set a bucket policy. You can use Amazon's policy generator if needed. Simply save this policy to your bucket properties. Here's a tutorial if needed:http://www.jppinto.com/2011/12/access-denied-to-file-amazon-s3-bucket/.

Login to your console here: https://console.aws.amazon.com/s3/home

Here's an example policy:

{
  "Id": "Policy1412292920796",
  "Statement": [
    {
      "Sid": "Stmt1412292914309",
      "Action": [
        "s3:GetObject",
        "s3:PutObject"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::tzmartin.com.files/*",
      "Principal": {
        "AWS": [
          "*"
        ]
      }
    }
  ]
}

Upload an image, then visit the bucket: https://s3.amazonaws.com/BUCKETNAME/FILENAME.png

Easy Peasy Lemon Squeezy

Titanium SDK Compilation

You must have the following requirements to compile this app:

  • A valid Appcelerator Platform account (free or paid):
    • Sign up for an Appcelerator Platform account
  • Appcelerator Studio should be installed and ready for use
  • The latest Titanium SDK installation (requirements)
  • Oracle JDK
  • Node.js: required for the Titanium command-line tools like the CLI, Alloy and Arrow.
  • iOS and/or Android SDK installation

Note: To minimize the risk of problems, please refer to the Titanium Compatibility Matrix whenever you make changes to your Titanium environment.

Changelog

  • 07-29-2016
    • Update README: add example app
    • Bump to Ti SDK v5.3.1.GA
  • 05-13-2015
    • Android works! (Fixed: Android fails to upload properly. 400 server response.)
    • Bump Ti SDK v5.2.2.GA
  • 10-2-2014
    • Complete app rewrite to 3.4.0.GA SDK
    • Demo app now runs Alloy 1.4
    • Removed additional module depencies. Now it's a single commonJS file.
    • Simplified constructor and removed config and load methods. Now just pass properties to PUT.
  • 3-8-2012
    • Initial release

Known Issues:

Create a ticket

License

@authors

@license

Copyright (c) 2011, Semantic Press, Inc. http://www.semanticpress.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Amazon S3 CommonJS module for Appcelerator Alloy / Titanium SDK

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published