Giter Site home page Giter Site logo

lalasland / amazons3fileuploaderbeta Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aaronksaunders/amazons3fileuploaderbeta

2.0 0.0 0.0 19.67 MB

Amazon S3 File Uploader IOS Module BETA

License: Other

Python 0.31% Objective-C 99.65% JavaScript 0.05%

amazons3fileuploaderbeta's Introduction

AmazonS3FileUploaderBETA

Amazon S3 File Uploader IOS Module BETA

Clearly Innovative Inc

s3uploader Module

Description

Simple file upload and bucket management for Amazon Simple Storage Service (Amazon S3) written for IOS and Titanium Appcelerator.

Download IOS Module Here

Accessing the s3uploader Module

To access this module from JavaScript, you would do the following:

var s3uploader = require('com.ci.s3uploader')
var proxy = s3uploader.create({
    "ACCESS_KEY_ID": "XXXXXXXXXXXXXXXXXXXXXXX",
    "SECRET_KEY": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
});

The s3uploader variable is a reference to the Module object we then create the proxy object we will actually use.

Reference

TODO: If your module has an API, you should document the reference here.

listBuckets

will list all buckets

// list all Buckets
proxy.listBuckets({
    "BUCKET_NAME" : "people-interact"
}, callback);

listBucketContents

will list all files in the specified bucket

// list all items in an S3 Bucket
proxy.listBucketContents({
    "BUCKET_NAME" : "people-interact"
}, callback);

deleteBucket

will delete a specified bucket

    // delete a bucket
    proxy.deleteBucket({
	    "BUCKET_NAME" : "people-interact"
    }, callback);

deleteBucketItem

will delete a specified bucket item

// delete a bucket
proxy.deleteBucketItem({
	"PATH" : "photo.data/aaron-pic.jpg",
	"BUCKET_NAME" : "people-interact"
}, callback);

uploadToAS3

will upload file/blob to specified path and S3 Bucket

// upload a file to an S3 Bucket
var f = Ti.Filesystem.getFile("aaron-pic.jpg");
proxy.uploadToAS3(f.read(), {
	"PATH" : "photo.data/aaron-pic.jpg",
	"BUCKET_NAME" : "people-interact"
}, callback);

sample response from success file upload, returns file information and a url that is good for about 60 minutes before it expires. use method below to get new url when needed

{
    "type": "success",
    "source": {},
    "mimeType": "application/pdf",
    "success": true,
    "url": "https://people-interact.s3.amazonaws.com/pdf.data%2FModule-Developers-Guide-iOS.pdf?AWSAccessKeyId=AKIAJSHYUI4MJHKQ4HBQ&Expires=1337493797&response-content-type=application%2Fpdf&Signature=xRaO4uvUQGrlLR7vavEZjei2Uwc%3D"
}

urlFromAS3

will get a url for the specified resource in the S3 bucket

// get the URL from an item in an S3 Bucket
proxy.urlFromAS3({
	"PATH" : "photo.data/aaron-pic.jpg",
	"BUCKET_NAME" : "people-interact"
}, callback);

Using the callback method

function(_data) {
    Ti.API.info("data " + JSON.stringify(_data));
});

Callback response information example

{
    "type": "success",
    "source": {
        "id": "com.ci.s3uploader"
    },
    "success": true,
    "contents": [
        {
            "owner_displayName": "aaron",
            "name": "Untitled.omniplan",
            "etag": "\"9ada9c606ba3300f5f83a21981eec4cf\"",
            "owner_id": "34ff3c085c6e2e191d51b92069e4dd9990f3846523fb7e9376d1eee9c2f958ee",
            "size": "15708",
            "lastModified": "2012-05-14T02:01:27.000Z"
        },
        {
            "owner_displayName": "aaron",
            "name": "photo.data/aaron-pic.jpg",
            "etag": "\"cc974e09dd7c30a4185702ba2120b631\"",
            "owner_id": "34ff3c085c6e2e191d51b92069e4dd9990f3846523fb7e9376d1eee9c2f958ee",
            "size": "16251",
            "lastModified": "2012-05-14T01:57:25.000Z"
        }
    ]
}

Author

Clearly Innovative Inc 2012 Aaron K. Saunders

twitter: @aaronksaunders

linkedin: http://www.linkedin.com/in/aaronksaunders

blog: blog.clearlyinnovative.com

License

Copyright (c) 2012-2013 Aaron K. Saunders

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.

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.