@avergara/nativescript-aws-sdk
by avergara | v0.0.2
A NativeScript plugin using the Native sdks
npm i --save @avergara/nativescript-aws-sdk

NativeScript AWS SDK

npm npm Build Status

Installation

NativeScript 7x

  • ns plugin add @avergara/nativescript-aws-sdk

Usage

Android

Add the following services in the app/App_Resources/Android/AndroidManifest.xml

<manifest ... >
<application ... >
...
<service android:name= "com.amazonaws.mobileconnectors.s3.transferutility.TransferService" android:enabled="true" />
</application>
</manifest>

TypeScript

S3

import { S3 } from 'nativescript-aws-sdk';
S3.init({ endPoint: '', accessKey: '', secretKey: '', type: 'static' }); // <= Try calling this before the app starts
import { S3 } from 'nativescript-aws-sdk';
const s3 = new S3();
const imageUploaderId = s3.createUpload({
file: '~/assets/hulk_wolverine_x_men.jpg',
bucketName: 'yaychat',
key: `ns_${isIOS ? 'ios' : 'android'}_hulk_wolverine_x_men.jpg`,
acl: 'public-read',
completed: (error, success) => {
if (error) {
console.log(`Download Failed :-> ${error.message}`);
}
if (success) {
console.log(`Download Complete :-> ${success.path}`);
}
},
progress: progress => {
console.log(`Progress : ${progress.value}`);
}
});

s3.pause(imageUploaderId);
s3.resume(imageUploaderId);
s3.cancel(imageUploaderId);

JavaScript

const S3 = require('nativescript-aws-sdk').S3;
S3.S3.init({ endPoint: '', accessKey: '', secretKey: '', type: 'static' }); // <= Try calling this before the app starts
const imageUploaderId = s3.createUpload({
file: '~/assets/hulk_wolverine_x_men.jpg',
bucketName: 'yaychat',
key: `ns_${isIOS ? 'ios' : 'android'}_hulk_wolverine_x_men.jpg`,
acl: 'public-read',
completed: (error, success) => {
if (error) {
console.log(`Download Failed :-> ${error.message}`);
}
if (success) {
console.log(`Download Complete :-> ${success.path}`);
}
},
progress: progress => {
console.log(`Progress : ${progress.value}`);
}
});

s3.pause(imageUploaderId);
s3.resume(imageUploaderId);
s3.cancel(imageUploaderId);

Api

S3

Method Default Type Description
createDownload(options: S3DownloadOptions) number Creates a task it returns the id of the task
createUpload(options: S3UploadOptions) number Creates a task it returns the id of the task
resume(id: number) void Resumes a task.
cancel(id: number) void Cancels a task.
pause(id: number) void Pauses a task.

Example Image

IOS Android
IOS Android