Giter Club home page Giter Club logo

react-native-s3's Introduction

React Native AWS S3

NPM version Build Status Dependency Status devDependency Status

A React Native wrapper for AWS iOS/Android S3 SDK.

We currently implements TransferUtility, see iOS/Android docs for more information.

Known issues

  • Currently reload js will lead TransferUtility not work. (#9)

Installation

$ npm install react-native-s3 --save

Setup

iOS

In XCode, in the project navigator:

  • Right click LibrariesAdd Files to [your project's name], Add node_modules/react-native-s3/ios/RNS3.xcodeproj.
  • Add libRNS3.a to your project's Build PhasesLink Binary With Libraries
  • Add $(SRCROOT)/../node_modules/react-native-s3/ios to Header Search Paths, and mark it as recursive.
  • Add $(SRCROOT)/../node_modules/react-native-s3/ios/Frameworks to your project's Build SettingsFramework Search Paths
  • Add node_modules/react-native-s3/ios/Frameworks/*.framework, libsqlite3.tbd, libz.tbd to your project's Build PhasesLink Binary With Libraries
  • Edit AppDelegate.m of your project
#import "RNS3TransferUtility.h"

......

- (void)application:(UIApplication *)application handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler:(void (^)())completionHandler {
  [RNS3TransferUtility interceptApplication:application
        handleEventsForBackgroundURLSession:identifier
                          completionHandler:completionHandler]
}
  • [Optional] you can set the credentials in AppDelegate.m
#import "RNS3TransferUtility.h"

......

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [[RNS3TransferUtility nativeCredentialsOptions] setObject:@"eu-west-1" forKey:@"region"];
  [[RNS3TransferUtility nativeCredentialsOptions] setObject:[NSNumber numberWithInt:[RNS3TransferUtility credentialType:@"BASIC"]] forKey:@"type"];
  [[RNS3TransferUtility nativeCredentialsOptions] setObject:@"your_access_key_here" forKey:@"access_key"];
  [[RNS3TransferUtility nativeCredentialsOptions] setObject:@"your_secret_key_here" forKey:@"secret_key"];
  ......
}

Android

  • Edit android/settings.gradle of your project:
...
include ':react-native-s3'
project(':react-native-s3').projectDir = new File(settingsDir, '../node_modules/react-native-s3/android')
  • Edit android/app/build.gradle of your project:
...
dependencies {
    ...
    compile project(':react-native-s3')
}
  • Add package to MainActivity
......

import com.mybigday.rn.*;   // import

public class MainActivity extends ReactActivity {

    ......

    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new RNS3Package()   // add package
        );
    }
}

You can use rnpm instead of above steps.

  • Edit android/app/src/main/AndroidManifest.xml of your project:
<service
  android:name="com.amazonaws.mobileconnectors.s3.transferutility.TransferService"
  android:enabled="true" />
  • [Optional] you can set the credentials in MainActivity:
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  RNS3TransferUtility.nativeCredentialsOptions.put("region", "eu-west-1");
  RNS3TransferUtility.nativeCredentialsOptions.put("type", RNS3TransferUtility.CredentialType.BASIC);
  RNS3TransferUtility.nativeCredentialsOptions.put("access_key", "your_access_key_here");
  RNS3TransferUtility.nativeCredentialsOptions.put("secret_key", "your_secret_key_here");
}

The nativeCredentialsOptions type

  • BASIC
  • COGNITO

Usage

import { transferUtility } from 'react-native-s3';

See API.md for more information.

Alternatives

  • react-native-aws3 - if you don't need the native library provided background upload/download task features.

License

MIT

react-native-s3's People

Contributors

jhen0409 avatar falsecz avatar

Watchers

James Cloos avatar  avatar

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.