private S3TransferHelper(final Context context, final AmazonS3Client s3Client, final String bucket, final String s3DirPrefix, final String localTransferPath, final LocalContentCache cache) { this.bucket = bucket; this.s3DirPrefix = s3DirPrefix == null ? "" : s3DirPrefix; this.localContentCache = cache; if (localTransferPath.endsWith(DIR_DELIMITER)) { this.localTransferPath = localTransferPath; } else { this.localTransferPath = localTransferPath + DIR_DELIMITER; } transferUtility = new TransferUtility(s3Client, context); transfersInProgress = new HashMap<>(); managedFilesToTransfers = new HashMap<>(); progressListeners = new HashMap<>(); }
public synchronized void provideCredentials(@NonNull String bucket, @NonNull String bucketPath, @NonNull String awsKey, @NonNull String awsSecret, @NonNull String awsSessionToken) { if (hasCredentials()) { Timber.w("Credentials already provided"); return; } Timber.d("Credentials provided"); this.bucket = bucket; this.bucketPath = bucketPath; this.credentials = new BasicSessionCredentials(awsKey, awsSecret, awsSessionToken); this.s3 = new AmazonS3Client(credentials); this.transferUtility = new TransferUtility(s3, context); executeQueuedUploads(); }
NetworkStore() { kwalaCookieStore = new KwalaCookieStore(KwalaApplication.getInstance()); CookieManager cookieManager = new CookieManager(kwalaCookieStore, CookiePolicy.ACCEPT_ORIGINAL_SERVER); CookieHandler.setDefault(cookieManager); okHttpClient = new OkHttpClient.Builder() .cookieJar(new JavaNetCookieJar(cookieManager)) .authenticator(authenticator) .readTimeout(30, TimeUnit.SECONDS) .writeTimeout(30, TimeUnit.SECONDS) .build(); KwalaApplication application = KwalaApplication.getInstance(); // Initialize the Amazon Cognito credentials provider CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(application, KwalaConstants.Network.AWS_IDENTITY_POOL_ID, Regions.US_EAST_1 ); // Initialize Amazon S3 and transfer utility s3Client = new AmazonS3Client(credentialsProvider); transferUtility = new TransferUtility(s3Client, application); }
/** * Initializes the AWS S3 credentials provider and transfer manager */ public static void init(Context context) { // Initialize the Amazon Cognito credentials provider CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider( context.getApplicationContext(), // Context AWS_IDENTITY_POOL_ID, // Identity Pool ID AWS_REGION // Region ); mS3Client = new AmazonS3Client(credentialsProvider); sTransferUtility = new TransferUtility(mS3Client, context); }
public static void init(Context context) { transferUtility = new TransferUtility(getS3Client(context), context); BUCKET_ID = context.getString(R.string.amazon_s3_bucket_id); }
public static TransferUtility getTransferUtility() { return transferUtility; }