package com.nestedworld.nestedworld.helpers.aws;

import android.content.Context;
import android.graphics.Bitmap;
import android.support.annotation.NonNull;

import com.amazonaws.auth.CognitoCachingCredentialsProvider;
import com.amazonaws.mobileconnectors.s3.transferutility.TransferUtility;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;

import java.io.File;

public final class AwsHelper {
    private AwsHelper() {
        //Private constructor for avoiding this class to be construct
    }

    public static void upload(@NonNull final Context context, @NonNull final File file) {
        //TODO use good credential
        CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
                context.getApplicationContext(),
                "COGNITO_IDENTITY_POOL",
                Regions.EU_CENTRAL_1
        );

        //TODO check the doc
        AmazonS3 s3 = new AmazonS3Client(credentialsProvider);
        TransferUtility transferUtility = new TransferUtility(s3, context);
        transferUtility.upload(null, "picture", file);
    }
}

@@ -79,40 +79,8 @@
 xt;%0A
-import android.graphics.Bitmap;%0A
 impo
@@ -123,274 +123,8 @@
 l;%0A%0A
-import com.amazonaws.auth.CognitoCachingCredentialsProvider;%0Aimport com.amazonaws.mobileconnectors.s3.transferutility.TransferUtility;%0Aimport com.amazonaws.regions.Regions;%0Aimport com.amazonaws.services.s3.AmazonS3;%0Aimport com.amazonaws.services.s3.AmazonS3Client;%0A%0A
 impo
@@ -408,16 +408,18 @@
         
+//
 CognitoC
@@ -505,32 +505,34 @@
 ovider(%0A        
+//
         context.
@@ -556,32 +556,34 @@
 text(),%0A        
+//
         %22COGNITO
@@ -603,24 +603,26 @@
 L%22,%0A        
+//
         Regi
@@ -646,16 +646,18 @@
         
+//
 );%0A%0A    
@@ -689,16 +689,18 @@
         
+//
 AmazonS3
@@ -754,16 +754,18 @@
         
+//
 Transfer
@@ -832,16 +832,18 @@
         
+//
 transfer

comment aws integration