Code Monkey home page Code Monkey logo

aws-sdk-android's Introduction

AWS Amplify

current aws-amplify package version weekly downloads GitHub Workflow Status (with event) code coverage join discord

Reporting Bugs / Feature Requests

Open Bugs Feature Requests Closed Issues

Note aws-amplify 6 has been released. If you are looking for upgrade guidance click here

AWS Amplify is a JavaScript library for frontend and mobile developers building cloud-enabled applications

AWS Amplify provides a declarative and easy-to-use interface across different categories of cloud operations. AWS Amplify goes well with any JavaScript based frontend workflow and React Native for mobile developers.

Our default implementation works with Amazon Web Services (AWS), but AWS Amplify is designed to be open and pluggable for any custom backend or service.

Visit our documentation site to learn more about AWS Amplify. Please see the Amplify JavaScript page for information around the full list of features we support.

Features

Category AWS Provider Description
Authentication Amazon Cognito APIs and Building blocks to create Authentication experiences.
Analytics Amazon Pinpoint Collect Analytics data for your application including tracking user sessions.
REST API Amazon API Gateway Sigv4 signing and AWS auth for API Gateway and other REST endpoints.
GraphQL API AWS AppSync Interact with your GraphQL or AWS AppSync endpoint(s).
DataStore AWS AppSync Programming model for shared and distributed data, with simple online/offline synchronization.
Storage Amazon S3 Manages content in public, protected, private storage buckets.
Geo (Developer preview) Amazon Location Service Provides APIs and UI components for maps and location search for JavaScript-based web apps.
Push Notifications Amazon Pinpoint Allows you to integrate push notifications in your app with Amazon Pinpoint targeting and campaign management support.
Interactions Amazon Lex Create conversational bots powered by deep learning technologies.
PubSub AWS IoT Provides connectivity with cloud-based message-oriented middleware.
Internationalization --- A lightweight internationalization solution.
Cache --- Provides a generic LRU cache for JavaScript developers to store data with priority and expiration settings.
Predictions Various* Connect your app with machine learning services like NLP, computer vision, TTS, and more.
  • Predictions utilizes a range of Amazon's Machine Learning services, including: Amazon Comprehend, Amazon Polly, Amazon Rekognition, Amazon Textract, and Amazon Translate.

Getting Started

AWS Amplify is available as aws-amplify on npm.

To get started pick your platform from our Getting Started home page

Notice:

Amplify 6.x.x has breaking changes. Please see the breaking changes on our migration guide

Amplify 5.x.x has breaking changes. Please see the breaking changes below:

  • If you are using default exports from any Amplify package, then you will need to migrate to using named exports. For example:

    - import Amplify from 'aws-amplify';
    + import { Amplify } from 'aws-amplify'
    
    - import Analytics from '@aws-amplify/analytics';
    + import { Analytics } from '@aws-amplify/analytics';
    // or better
    + import { Analytics } from 'aws-amplify';
    
    - import Storage from '@aws-amplify/storage';
    + import { Storage } from '@aws-amplify/storage';
    // or better
    + import { Storage } from 'aws-amplify';
  • Datastore predicate syntax has changed, impacting the DataStore.query, DataStore.save, DataStore.delete, and DataStore.observe interfaces. For example:

    - await DataStore.delete(Post, (post) => post.status('eq', PostStatus.INACTIVE));
    + await DataStore.delete(Post, (post) => post.status.eq(PostStatus.INACTIVE));
    
    - await DataStore.query(Post, p => p.and( p => [p.title('eq', 'Amplify Getting Started Guide'), p.score('gt', 8)]));
    + await DataStore.query(Post, p => p.and( p => [p.title.eq('Amplify Getting Started Guide'), p.score.gt(8)]));
  • Storage.list has changed the name of the maxKeys parameter to pageSize and has a new return type that contains the results list. For example:

    - const photos = await Storage.list('photos/', { maxKeys: 100 });
    - const { key } = photos[0];
    
    + const photos = await Storage.list('photos/', { pageSize: 100 });
    + const { key } = photos.results[0];
  • Storage.put with resumable turned on has changed the key to no longer include the bucket name. For example:

    - let uploadedObjectKey;
    - Storage.put(file.name, file, {
    -   resumable: true,
    -   // Necessary to parse the bucket name out to work with the key
    -   completeCallback: (obj) => uploadedObjectKey = obj.key.substring( obj.key.indexOf("/") + 1 )
    - }
    
    + let uploadedObjectKey;
    + Storage.put(file.name, file, {
    +   resumable: true,
    +   completeCallback: (obj) => uploadedObjectKey = obj.key
    + }
  • Analytics.record no longer accepts string as input. For example:

    - Analytics.record('my example event');
    + Analytics.record({ name: 'my example event' });
  • The JS export has been removed from @aws-amplify/core in favor of exporting the functions it contained.

  • Any calls to Amplify.Auth, Amplify.Cache, and Amplify.ServiceWorker are no longer supported. Instead, your code should use the named exports. For example:

    - import { Amplify } from 'aws-amplify';
    - Amplify.configure(...);
    - // ...
    - Amplify.Auth.signIn(...);
    
    + import { Amplify, Auth } from 'aws-amplify';
    + Amplify.configure(...);
    + // ...
    + Auth.signIn(...);

Amplify 4.x.x has breaking changes for React Native. Please see the breaking changes below:

  • If you are using React Native (vanilla or Expo), you will need to add the following React Native community dependencies:
    • @react-native-community/netinfo
    • @react-native-async-storage/async-storage
// React Native
yarn add aws-amplify amazon-cognito-identity-js @react-native-community/netinfo @react-native-async-storage/async-storage
npx pod-install

// Expo
yarn add aws-amplify @react-native-community/netinfo @react-native-async-storage/async-storage

Amplify 3.x.x has breaking changes. Please see the breaking changes below:

If you can't migrate to aws-sdk-js-v3 or rely on [email protected], you will need to import it separately.

  • If you are using exported paths within your Amplify JS application, (e.g. import from "@aws-amplify/analytics/lib/Analytics") this will now break and no longer will be supported. You will need to change to named imports:

    import { Analytics } from 'aws-amplify';
  • If you are using categories as Amplify.<Category>, this will no longer work and we recommend to import the category you are needing to use:

    import { Auth } from 'aws-amplify';

DataStore Docs

For more information on contributing to DataStore / how DataStore works, see the DataStore Docs

aws-sdk-android's People

Contributors

aws-amplify-ops avatar awsmobilesdk avatar changxu0306 avatar desokroshan avatar div5yesh avatar eeatonaws avatar fosterzhang avatar frankmuellr avatar github-actions[bot] avatar gpanshu avatar jamesonwilliams avatar jpignata avatar karthiksaligrama avatar mattcreaser avatar minbi avatar palpatim avatar raphkim avatar richardmcclellan avatar rjuliano avatar rlatapy-luna avatar rohandubal avatar royjit avatar sdhuka avatar sirknightj avatar sktimalsina avatar thisisabhash avatar tjleing avatar treksoft avatar tylerjroach avatar wdane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-sdk-android's Issues

Decryption fails for default encryption mode AES/CBC/PKCS5Padding when RSA keypair is used to encrypt symmetric key

This issue exists from ancient times and prevents us from using sdk as a library and avoid patching it (as it's done now for 1.7.* based code).

Problem is when S3 object is encrypted using default encryption method using this symmetric key algorithm (and in case of AWS SDK for Android it's RSA):

this is the fix for that particular problem:
src/com/amazonaws/services/s3/internal/crypto/EncryptionUtils.java:

Method:
private static SecretKey getDecryptedSymmetricKey(byte[] encryptedSymmetricKeyBytes, EncryptionMaterials materials, Provider cryptoProvider) {

        byte[] decryptedSymmetricKeyBytes = cipher.doFinal(encryptedSymmetricKeyBytes);
  •        // Here is where Amazon SDK hits us with bug. If RSA algorithm is used for encryption of symmetric key,
    
  •        // it will skip leading zero bytes (1/256 chance for first byte in the key to be zero,
    
  •        // 1/65536 for second to be zero, etc. We should restore it or we won't be able
    
  •        // to decrypt the key and hence the file itself
    
  •        // http://www.bouncycastle.org/wiki/display/JA1/Frequently+Asked+Questions#FrequentlyAskedQuestions-4.WhenIencryptsomethingwithRSAIamlosingleadingzerobytesoffmydata,whyareyouguysshippingsuchabrokenimplementation?
    
  •        int shift = 32 - decryptedSymmetricKeyBytes.length;
    
  •        if (shift > 0) {
    
  •            byte[] recoveredDecryptedSymmetricKeyBytes = new byte[32];
    
  •            for (int i = shift; i < 32; i++) {
    
  •                recoveredDecryptedSymmetricKeyBytes[i] = decryptedSymmetricKeyBytes[i - shift];
    
  •            }
    
  •            decryptedSymmetricKeyBytes = recoveredDecryptedSymmetricKeyBytes;
    
  •        }
        return new SecretKeySpec(decryptedSymmetricKeyBytes, JceEncryptionConstants.SYMMETRIC_KEY_ALGORITHM);
    

The same fix should be done in AWS JAVA SDK: https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/internal/crypto/EncryptionUtils.java

No peer certificate

Hi, I am having an intermittent issue when I try to upload a set of images to a S3 bucket. Basically my application tries to upload a set of 40 – 50 images. But in middle of the process the SDK shows this error repeatedly. I have noted that it happens in newer android versions 4.4 or higher, but in 4.0 and 4.2 it doesn’t happen.

screen shot 2015-01-20 at 1 25 47 am

Crash aws-sdk-android-mobileanalytics 2.2.2 eventClient.submitEvents()

Hi,

I've been trying to integrate my application with AWS Analytics, I was able to successfully authenticate with cognito, and also get an instance of the MobileAnalyticsManager... BUT when my activity pauses, and eventClient attempts to submitEvents... my application crashes.

The stacktrace I'm getting, but I'm not quite sure if it's related... it's the following:

07-01 16:39:59.177 23841-27327/? I/AmazonHttpClient﹕ Unable to execute HTTP request: null
java.io.EOFException
at com.android.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:95)
at com.android.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:175)
at com.android.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:101)
at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:616)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:379)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:323)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseMessage(HttpURLConnectionImpl.java:487)
at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getResponseMessage(DelegatingHttpsURLConnection.java:109)
at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getResponseMessage(HttpsURLConnectionImpl.java:25)
at com.amazonaws.http.UrlHttpClient.createHttpResponse(UrlHttpClient.java:72)
at com.amazonaws.http.UrlHttpClient.execute(UrlHttpClient.java:66)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:353)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:196)
at com.amazonaws.services.mobileanalytics.AmazonMobileAnalyticsClient.invoke(AmazonMobileAnalyticsClient.java:335)
at com.amazonaws.services.mobileanalytics.AmazonMobileAnalyticsClient.putEvents(AmazonMobileAnalyticsClient.java:275)
at com.amazonaws.mobileconnectors.amazonmobileanalytics.internal.delivery.DefaultDeliveryClient.submitEvents(DefaultDeliveryClient.java:317)
at com.amazonaws.mobileconnectors.amazonmobileanalytics.internal.delivery.DefaultDeliveryClient$3.run(DefaultDeliveryClient.java:282)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)

How can I get this solved ?

Thanks!

EDIT: This was issued while running an AVD with API 21, haven't tried on a real device.

How can we generate auth header for S3 secure URL's

Feature Request:

Currently SDK provides feature to get the preSignedURL.
But we also need that the SDK should provide a way to generate authentication header.

That will enable these secure URL's to be downloaded and cached easily with all the image cache libraries available for example picasso, ion, UIL etc.

Thanks

Certificate Error for the preSighnedURL

Hi,
Amazon S3 SDK (v2.1.4) is successfully providing signed URL

URL url = sS3Client.generatePresignedUrl("<BUCKET_NAME>", "<FILENAME>", nowPlus10Minutes.getTime());

But when I use that URL to fetch the image through HTTPURLConnection there is an security error for certificate. (FYI I am using picasso for downloading the image, that's where HTTPURLConnectionc comes in scene)

And when I try the URL in chrome I had the same problem
*Server could not prove that its security certificate from .s3.amazon.com

Altough in browser one can add the hosts in exception and by doing that I am able to download the Image through chrome.

Please let me know why this is happening, Am I missing someting ?

Thanks
Rahul

Failing to upload image after ~30-40 minutes

We can authenticate with Cognito using Digits and upload images; however, after about 30 to 40 minutes of just having the app sit there, we get an error saying we can't access it when trying to upload a new image. Seen below:

com.amazonaws.services.cognitoidentity.model.NotAuthorizedException: Access to Identity 'us-east-1:NotTheActualPoolId' is forbidden. (Service: AmazonCognitoIdentity; Status Code: 400; Error Code: NotAuthorizedException; Request ID: 96d61bb5-3553-11e5-ae36-8be8ef351d5f)

The second time we try to upload the image, immediately after the first error, we get:

Unauthenticated access is not supported for this identity pool. (Service: AmazonCognitoIdentity; Status Code: 400; Error Code: NotAuthorizedException; Request ID: a9b498c2-3557-11e5-be30-5b1603ee422d)

It looks like the first error clears our credentials and the second makes sense since we don't have credentials anymore and we have unauthenticated access turned off in Cognito.

Any ideas?

No CloudFront in Android SDK

Hi,

Do you know how can i generate a signedURL for consuming private S3 content served through CloudFront? i cant seem to find any information on this.
I can generate signedURL from S3 and consume the files from there, but doing this through CloudFront seems impossible.
Thanks

pom.xml?

The v1 repo contained a POM file to facilitate building and resolution of dependencies. Can you do the same for v2?

v2.0.5 Another initialisation error

I am using AWS S3 SDK (v2.0.5) on my Android project. It runs fine without Proguard, however, with Proguard it throws the following exceptions:

08-28 12:39:39.054: W/dalvikvm(5152): Exception Ljava/lang/IllegalStateException; thrown while initializing Lcom/amazonaws/internal/config/InternalConfig$Factory;
08-28 12:39:39.064: W/dalvikvm(5152): threadid=10: thread exiting with uncaught exception (group=0x418de378)
08-28 12:39:39.074: E/AndroidRuntime(5152): FATAL EXCEPTION: AsyncTask #1
08-28 12:39:39.074: E/AndroidRuntime(5152): java.lang.RuntimeException: An error occured while executing doInBackground()
08-28 12:39:39.074: E/AndroidRuntime(5152):     at android.os.AsyncTask$3.done(AsyncTask.java:299)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at java.lang.Thread.run(Thread.java:856)
08-28 12:39:39.074: E/AndroidRuntime(5152): Caused by: java.lang.ExceptionInInitializerError
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.amazonaws.ServiceNameFactory.getServiceName(SourceFile:34)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.amazonaws.AmazonWebServiceClient.computeServiceName(SourceFile:707)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.amazonaws.AmazonWebServiceClient.getServiceNameIntern(SourceFile:680)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.amazonaws.AmazonWebServiceClient.computeSignerByURI(SourceFile:282)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.amazonaws.AmazonWebServiceClient.setEndpoint(SourceFile:160)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.amazonaws.services.s3.AmazonS3Client.setEndpoint(SourceFile:472)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.amazonaws.services.s3.AmazonS3Client.init(SourceFile:444)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.amazonaws.services.s3.AmazonS3Client.(SourceFile:340)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.amazonaws.services.s3.AmazonS3Client.(SourceFile:320)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.company.app.service.S3Client.(SourceFile:29)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.company.app.service.S3Client.getInstance(SourceFile:120)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at aeo.a(SourceFile:396)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at aeo.doInBackground(SourceFile:264)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
08-28 12:39:39.074: E/AndroidRuntime(5152):     ... 5 more
08-28 12:39:39.074: E/AndroidRuntime(5152): Caused by: java.lang.IllegalStateException: Fatal: Failed to load the internal config for AWS Java SDK
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.amazonaws.internal.config.InternalConfig$Factory.(SourceFile:236)
08-28 12:39:39.074: E/AndroidRuntime(5152):     ... 20 more
08-28 12:39:39.074: E/AndroidRuntime(5152): Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.amazonaws.internal.config.Builder, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information
08-28 12:39:39.074: E/AndroidRuntime(5152):  at [Source: jar:file:/data/app/com.company.app-1.apk!/awssdk_config_default.json; line: 9, column: 18] (through reference chain: com.amazonaws.internal.config.InternalConfigJsonHelper["serviceSigners"]->com.amazonaws.internal.config.JsonIndex["config"])
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.fasterxml.jackson.databind.DeserializationContext.instantiationException(SourceFile:624)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserialize(SourceFile:115)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SourceFile:375)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(SourceFile:107)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(SourceFile:308)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(SourceFile:121)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(SourceFile:147)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(SourceFile:18)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SourceFile:375)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(SourceFile:98)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(SourceFile:308)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(SourceFile:121)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(SourceFile:2796)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.fasterxml.jackson.databind.ObjectMapper.readValue(SourceFile:1919)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.amazonaws.internal.config.InternalConfig.loadfrom(SourceFile:182)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.amazonaws.internal.config.InternalConfig.load(SourceFile:199)
08-28 12:39:39.074: E/AndroidRuntime(5152):     at com.amazonaws.internal.config.InternalConfig$Factory.(SourceFile:230)
08-28 12:39:39.074: E/AndroidRuntime(5152):     ... 20 more

Any idea how to solve this?

The above exceptions were thrown regardless of whether I linked my app with the debug or release JAR files.

I saw that there is another issue on initialisation error #2, I did try that, but no luck.

The settings of my Proguard are as follows:

##---------------Begin: proguard configuration common for all Android apps ----------
-optimizationpasses 2
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontpreverify
-verbose
-dump class_files.txt
-printseeds seeds.txt
-printusage unused.txt
-printmapping mapping.txt
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*

-allowaccessmodification
-keepattributes *Annotation*
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-repackageclasses ''

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-dontnote com.android.vending.licensing.ILicensingService

# Explicitly preserve all serialization members. The Serializable interface
# is only a marker interface, so it wouldn't save them.
-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

# Preserve all native method names and the names of their classes.
-keepclasseswithmembernames class * {
    native ;
}

-keepclasseswithmembernames class * {
    public (android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembernames class * {
    public (android.content.Context, android.util.AttributeSet, int);
}

# Preserve static fields of inner classes of R classes that might be accessed
# through introspection.
-keepclassmembers class **.R$* {
  public static ;
}

# Preserve the special static methods that are required in all enumeration classes.
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep public class * {
    public protected *;
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version.  We know about them, and they are safe.
-dontwarn android.support.**

# Remove all logs:
-assumenosideeffects class android.util.Log {
    public static boolean isLoggable(java.lang.String, int);
    public static int v(...);
    public static int i(...);
    public static int w(...);
    public static int d(...);
    public static int e(...);
}


##---------------End: proguard configuration common for all Android apps ----------

# AWS SDK
-keep class org.apache.commons.logging.**               { *; }
-keep class com.amazonaws.services.sqs.QueueUrlHandler  { *; }
-keep class com.amazonaws.javax.xml.transform.sax.*     { public *; }
-keep class com.amazonaws.javax.xml.stream.**           { *; }
-keep class com.amazonaws.services.**.model.*Exception* { *; }
-keep class com.amazonaws.internal.**                   { *; }
-keep class org.codehaus.**                             { *; }
-keep class org.joda.convert.*                          { *; }
-keep class org.joda.time.tz.Provider                   { *; }
-keep class org.joda.time.tz.NameProvider               { *; }
-keepattributes Signature,*Annotation*,EnclosingMethod
-keepnames class com.fasterxml.jackson.** { *; }
-keepnames class com.amazonaws.** { *; }

-dontwarn com.amazonaws.auth.policy.conditions.S3ConditionFactory
-dontwarn org.joda.time.**
-dontwarn com.fasterxml.jackson.databind.**
-dontwarn javax.xml.stream.events.**
-dontwarn org.codehaus.jackson.**
-dontwarn org.apache.commons.logging.impl.**
-dontwarn org.apache.http.conn.scheme.**
-dontwarn org.apache.http.annotation.**
-dontwarn org.ietf.jgss.**
-dontwarn org.w3c.dom.bootstrap.**

-dontnote com.amazonaws.services.sqs.QueueUrlHandler


# httpmime-4.3.3
-keepnames class org.apache.** {*;}
-keep public class org.apache.** {*;}


# This dnsjava class uses old Sun API
-dontnote org.xbill.DNS.spi.DNSJavaNameServiceDescriptor
-dontwarn org.xbill.DNS.spi.DNSJavaNameServiceDescriptor


# aSmack specific configuration
-keep class de.measite.smack.AndroidDebugger { *; }
-keep class * implements org.jivesoftware.smack.initializer.SmackInitializer
-keep class * implements org.jivesoftware.smack.provider.IQProvider
-keep class * implements org.jivesoftware.smack.provider.PacketExtensionProvider
-keep class * extends org.jivesoftware.smack.packet.Packet
-keep class org.jivesoftware.smack.XMPPConnection
-keep class org.jivesoftware.smack.XMPPTCPConnection
-keep class org.jivesoftware.smack.ReconnectionManager
-keep class org.jivesoftware.smackx.muc.MultiUserChat
-keep class org.jivesoftware.smackx.iqlast.LastActivityManager
-keep class org.jivesoftware.smackx.ping.PingManager
-keep class org.jivesoftware.smackx.privacy.PrivacyListManager
-keep class org.jivesoftware.smackx.time.EntityTimeManager
-keep class org.jivesoftware.smackx.vcardtemp.VCardManager
-keep class org.jivesoftware.smackx.chatmarkers.ChatMarkerManager


# Misc
-dontnote android.os.SystemProperties
-dontnote sun.security.pkcs11.SunPKCS11


# Google Play Services
-keep class * extends java.util.ListResourceBundle {
    protected java.lang.Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}

Look forward to any suggestions/comments on this. Many thanks

SDK doesn't upload .mp4 correctly in multiple parts

I am trying to upload item from Android client to China bucket. It is ~20 seconds video (~50mb) with hight resolution. It is separated in multiple chunks and each of them successfully uploaded:

  • I receive ProgressEvent.PART_COMPLETED_EVENT_CODE for all of them
  • I track how much bytes are transfered and it fully reach the size of the video

When I receive the last ProgressEvent.PART_COMPLETED_EVENT_CODE SDK stops send any events codes -- looks like it done his job. I checked the data on the server but got an error "NoSuchKey"

Observed behaviour:
SDK doesn't return ProgressEvent.COMPLETED_EVENT_CODE. Amazon via web request returns "NoSuchKey" error

Expected behaviour:
SDK returns ProgressEvent.COMPLETED_EVENT_CODE. Amazon via web request returns uploaded video.

Environment:
Nexus 5, Android 5.1
AWS SDK 2.2.2
Region "cn-north-1"

Setting md5 while uploading a file to s3

I am using amazon s3 android low level sdk to upload a file and want to set md5 checksum to upload data.

1)Following is the code to create credentials:

BasicAWSCredentials lAwsCredentials = new BasicAWSCredentials(
Constants.ACCESS_KEY_ID, Constants.SECRET_KEY);

AmazonS3Client lS3Client = new AmazonS3Client(lAwsCredentials);

2)Following is the code to calculate md5

public class MD5CheckSum {

public static byte[] createChecksum(String pFilepath) throws Exception {
InputStream lFis = new FileInputStream(pFilepath);

byte[] lBuffer = new byte[1024];
MessageDigest lMessageDigest = MessageDigest.getInstance("MD5");

int lNumRead;

do {
    lNumRead = lFis.read(lBuffer);
    if (lNumRead > 0) {
        lMessageDigest.update(lBuffer, 0, lNumRead);
    }
} while (lNumRead != -1);

lFis.close();
return lMessageDigest.digest();

}

public static String getMD5Checksum(String pFilepath) throws Exception {
byte[] lBytes = createChecksum(pFilepath);
return Base64.encodeToString(lBytes, Base64.DEFAULT);
}
}

3)Following is the code to set md5 using metadata:

try {
lMd5 = MD5CheckSum.getMD5Checksum(pFile.getAbsolutePath());

    Log.v(TAG, "CheckSum:====" + lMd5);
} catch (Exception lException) {
    lException.printStackTrace();
}

ObjectMetadata lObjectMetadata = new ObjectMetadata();
if (lMd5 != null) {
    lObjectMetadata.setContentMD5(lMd5);

}`

InitiateMultipartUploadResult mInitResponse = mS3Client.initiateMultipartUpload(new InitiateMultipartUploadRequest(mBucketName, mKeyName,
lObjectMetadata);
But a exception is thrown by amazon when i set md5:

Caused by: com.amazonaws.services.s3.model.AmazonS3Exception: Anonymous users cannot initiate multipart uploads. Please authenticate. (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: BA0C68FC884703FD), S3 Extended Request ID: re2sdbzf8MMqGAyrNQOoqYJ8EdXERoWE7cjG+UpfAtFuP5IeAbXmk6Riw+PX8Uw3Jcspn1rSQvI=

Is this the correct way to set md5?

Note: When md5 is not set(ie objectmetadata is not set) then upload works without any exception

Getting md5 null when downloading a file

Reference issue: #12

At download end i am getting md5 null.
Following is the code i am using to get md5 .Please let me know if it is correct way:

GetObjectMetadataRequest lGetObjectMetadataRequest = new GetObjectMetadataRequest(
mBucket, mKey);

ObjectMetadata lObjectMetadata = mS3Client
.getObjectMetadata(lGetObjectMetadataRequest);

    if (lObjectMetadata != null)
        Log.v(TAG, "Checksum:" + lObjectMetadata.getContentMD5());

SDK produces a lost of warning at build time

Aws Android SDK: 2.0.5

:app:dexDebug
warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.amazonaws.javax.xml.stream.StaxErrorReporter$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.amazonaws.javax.xml.stream.XMLReaderImpl$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.amazonaws.javax.xml.stream.xerces.util.SecuritySupport12$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.amazonaws.javax.xml.stream.xerces.util.SecuritySupport12$2) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.amazonaws.javax.xml.stream.xerces.util.SecuritySupport12$3) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.amazonaws.javax.xml.stream.xerces.util.SecuritySupport12$4) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$2) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$3) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$4) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$5) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$6) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.

Jackson is still used in 2.1.9

According to the http://aws.amazon.com/releasenotes/0908276529378471 one of the changes is: Replacing Jackson with Gson 2.2.4 in the core runtime library. The file size is reduced to 1.3Mb and the total number of methods is down to 7.5k. Improve the performance of unmarshalling Json responses.

However, jackson-core-2.1.1.jar is still part of the SDK binary release and it's used in the https://github.com/aws/aws-sdk-android/blob/master/src/main/java/com/amazonaws/util/json/JacksonFactory.java

Should it be removed?

TransferManager.shutdownNow causes Android NetworkOnMainThreadException

Aws Android v 2.0.5

Maybe adding in the shutdown javadoc of that it needs to be called in a separate thread?

android.os.NetworkOnMainThreadException
            at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1144)
            at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.close(OpenSSLSocketImpl.java:996)
            at com.amazonaws.org.apache.http.impl.SocketHttpClientConnection.close(SocketHttpClientConnection.java:265)
            at com.amazonaws.org.apache.http.impl.conn.DefaultClientConnection.close(DefaultClientConnection.java:167)
            at com.amazonaws.org.apache.http.impl.conn.HttpPoolEntry.close(HttpPoolEntry.java:89)
            at com.amazonaws.org.apache.http.pool.AbstractConnPool.shutdown(AbstractConnPool.java:122)
            at com.amazonaws.org.apache.http.impl.conn.PoolingClientConnectionManager.shutdown(PoolingClientConnectionManager.java:289)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.amazonaws.http.conn.ClientConnectionManagerFactory$Handler.invoke(Unknown Source)
            at com.amazonaws.http.conn.$Proxy14.shutdown(Native Method)
            at com.amazonaws.http.AmazonHttpClient.shutdown(Unknown Source)
            at com.amazonaws.AmazonWebServiceClient.shutdown(Unknown Source)
            at com.amazonaws.services.s3.transfer.TransferManager.shutdownNow(Unknown Source)
            at com.amazonaws.services.s3.transfer.TransferManager.shutdownNow(Unknown Source)

How to work these packages?

do we have to use any other plugin or software to use these packages? can anyone tell me in detail how to use these packages.

Aws not working with non-google devices

My app have some google functionality like GCM,Google +,Google map with clustering.
Before implementing aws my app working well in all devices.
But after implementing aws my app stop working in non-google devices means app only work in Nexus device.
I tried lots but not found any solution.
But We have checked more and founded that there are some issue with aws-android-sdk-core-2.2.1 because this file contain some google classes so it may be conflict with other google classes.

Any one have idea why this issue comes ?

regions.xml, awssdk_config_default.json & mimetypes.xml should be deleted?

Unable to upload to S3 - SocketTimeoutException

Hi,

I just upgrade the android SDK to version 2.2.0, but unable to upload file to S3. Downloading and deleting file works, but uploading always has the exception below. We are using TransferManager and unauthenticated Cognito to connect to S3.

Previous version works, not sure any changes we need to be aware of when upgrading to 2.2.0?

Thanks

Unable to execute HTTP request: sendto failed: EPIPE (Broken pipe)
    java.net.SocketException: sendto failed: EPIPE (Broken pipe)
            at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:546)
            at libcore.io.IoBridge.sendto(IoBridge.java:515)
            at java.net.PlainSocketImpl.write(PlainSocketImpl.java:504)
            at java.net.PlainSocketImpl.access$100(PlainSocketImpl.java:37)
            at java.net.PlainSocketImpl$PlainSocketOutputStream.write(PlainSocketImpl.java:266)
            at com.android.okio.Okio$1.write(Okio.java:70)
            at com.android.okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:116)
            at com.android.okio.RealBufferedSink.write(RealBufferedSink.java:44)
            at com.android.okhttp.internal.http.HttpConnection$FixedLengthSink.write(HttpConnection.java:287)
            at com.android.okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:116)
            at com.android.okio.RealBufferedSink$1.write(RealBufferedSink.java:131)
            at com.amazonaws.http.UrlHttpClient.write(UrlHttpClient.java:155)
            at com.amazonaws.http.UrlHttpClient.createConnection(UrlHttpClient.java:143)
            at com.amazonaws.http.UrlHttpClient.execute(UrlHttpClient.java:60)
            at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:361)
            at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:211)
            at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3838)
            at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1512)
            at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadCallable.uploadInOneChunk(UploadCallable.java:131)
            at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadCallable.call(UploadCallable.java:123)
            at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadMonitor.upload(UploadMonitor.java:185)
            at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadMonitor.call(UploadMonitor.java:143)
            at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadMonitor.call(UploadMonitor.java:53)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:818)
     Caused by: android.system.ErrnoException: sendto failed: EPIPE (Broken pipe)
            at libcore.io.Posix.sendtoBytes(Native Method)
            at libcore.io.Posix.sendto(Posix.java:176)
            at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:278)
            at libcore.io.IoBridge.sendto(IoBridge.java:513)
            at java.net.PlainSocketImpl.write(PlainSocketImpl.java:504)
            at java.net.PlainSocketImpl.access$100(PlainSocketImpl.java:37)
            at java.net.PlainSocketImpl$PlainSocketOutputStream.write(PlainSocketImpl.java:266)
            at com.android.okio.Okio$1.write(Okio.java:70)
            at com.android.okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:116)
            at com.android.okio.RealBufferedSink.write(RealBufferedSink.java:44)
            at com.android.okhttp.internal.http.HttpConnection$FixedLengthSink.write(HttpConnection.java:287)
            at com.android.okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:116)
            at com.android.okio.RealBufferedSink$1.write(RealBufferedSink.java:131)
            at com.amazonaws.http.UrlHttpClient.write(UrlHttpClient.java:155)
            at com.amazonaws.http.UrlHttpClient.createConnection(UrlHttpClient.java:143)
            at com.amazonaws.http.UrlHttpClient.execute(UrlHttpClient.java:60)
            at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:361)
            at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:211)
            at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3838)
            at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1512)
            at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadCallable.uploadInOneChunk(UploadCallable.java:131)
            at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadCallable.call(UploadCallable.java:123)
            at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadMonitor.upload(UploadMonitor.java:185)
            at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadMonitor.call(UploadMonitor.java:143)
            at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadMonitor.call(UploadMonitor.java:53)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:818)

Abstract HTTP logic

Would it be possible to abstract the HTTP logic?
Being able to choose between different HTTP client like Apache HttpClient or OkHTTP would be great.

Removing HttpClient would save ~900k in our APK and plenty of methods count. It would also have the advantages to use a more up to date HttpClient.

missing proguard definitions for com.amazonaws.org.apache.commons.logging

when trying to build a version with proguard using the S3 SDK, I crash upon trying to create a AmazonS3Client with this stack trace:

Caused by: com.amazonaws.org.apache.commons.logging.LogConfigurationException: No suitable Log implementation
    at com.amazonaws.org.apache.commons.logging.impl.LogFactoryImpl.bx(SourceFile:604)
    at com.amazonaws.org.apache.commons.logging.impl.LogFactoryImpl.bq(SourceFile:336)
    at com.amazonaws.org.apache.commons.logging.impl.LogFactoryImpl.V(SourceFile:310)
    at com.amazonaws.org.apache.commons.logging.LogFactory.W(SourceFile:685)
    at com.amazonaws.AmazonWebServiceClient.<clinit>(Unknown Source)
    ... 16 more

after adding the following definition in my proguard.cfg this was fixed
-keep class com.amazonaws.org.apache.commons.logging.** { *; }

SSLException during upload file in the bucket in aws-sdk 2.2.4

SO thread: http://stackoverflow.com/questions/30565422/sslexception-due-uploading-item-for-amazon-service gave me hope, but unfortunately I have the same error.

Tried TransferManager and TransferUtility
Tried 2.1, 2.2.2, 2.2.4
Tried upload on Wifi, mobile transfer, Wifi + mobile transfer
Bucket: EU_WEST_1
Device: 5.1, API 22

On every one of them I have the same in log:

Unable to execute HTTP request: Write error: ssl=0x9dd68000: I/O error during system call, Connection reset by peer
    javax.net.ssl.SSLException: Write error: ssl=0x9dd68000: I/O error during system call, Connection reset by peer
            at com.android.org.conscrypt.NativeCrypto.SSL_write(Native Method)
            at com.android.org.conscrypt.OpenSSLSocketImpl$SSLOutputStream.write(OpenSSLSocketImpl.java:765)
            at com.android.okio.Okio$1.write(Okio.java:70)
            at com.android.okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:116)
            at com.android.okio.RealBufferedSink.write(RealBufferedSink.java:44)
            at com.android.okhttp.internal.http.HttpConnection$FixedLengthSink.write(HttpConnection.java:291)
            at com.android.okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:116)
            at com.android.okio.RealBufferedSink$1.write(RealBufferedSink.java:131)
...

I am just tired of juggling versions and classes, please give me a hint how to use S3 upload.

Problem with Jackson - "cannot find symbol method readValue"

Hi,

In our app, I copied aws-android-sdk-2.1.1-core.jar and aws-android-sdk-2.1.1-s3.jar in to my libs folder. The app uses Jackson library to parse Json, but it is already included in the AWS SDK jar file. It seems that the sdk reduces the methods inside the Jackson libs, hence when I tried to compile my app, I got many errors:

"cannot find symbol method readValue"
"cannot find symbol method writeValue"
"cannot find symbol method writeValueAsString"

I then try to add 3 Jackson jars into my project libs folder but it still fails. I also tried to add Jackson using Gradle, but still see above error.

Do you have any idea to make it work? Thanks

Best,
Thomas

v2.0.5 ExceptionInInitializerError

Version 2.0.5
I am having the following exception while creating a new TransferManager.

Caused by: java.lang.ExceptionInInitializerError
            at com.amazonaws.ServiceNameFactory.getServiceName(Unknown Source)
            at com.amazonaws.AmazonWebServiceClient.computeServiceName(Unknown Source)
            at com.amazonaws.AmazonWebServiceClient.getServiceNameIntern(Unknown Source)
            at com.amazonaws.AmazonWebServiceClient.computeSignerByURI(Unknown Source)
            at com.amazonaws.AmazonWebServiceClient.setEndpoint(Unknown Source)
            at com.amazonaws.services.s3.AmazonS3Client.setEndpoint(Unknown Source)
            at com.amazonaws.services.s3.AmazonS3Client.init(Unknown Source)
            at com.amazonaws.services.s3.AmazonS3Client.<init>(Unknown Source)
            at com.amazonaws.services.s3.AmazonS3Client.<init>(Unknown Source)
            at com.amazonaws.services.s3.transfer.TransferManager.<init>(Unknown Source)

I don't know if its related but there some Dex warning while building the application

warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$2) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$3) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$4) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$5) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$6) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.

SSLException during upload file in the bucket in aws-sdk 2.2.1

I upload my file to aws service from android. I configured it like this:

`   AwsMetadata awsMetadata = resultData.getParcelable(Params.CommandMessage.EXTRA_MESSAGE);
    AWSCredentials awsCredentials = new BasicAWSCredentials(
            awsMetadata.getAccountId(),
            awsMetadata.getSecretKey()
    );
    // set up region
    TransferManager transferManager = new TransferManager(awsCredentials);
    Region region = Region.getRegion(Regions.fromName(awsMetadata.getRegionEndpoint()));
    transferManager.getAmazonS3Client().setRegion(region);


    final MediaItem mediaItem = datasource.get(0);
    Log.d(App.TAG, "File is exists: "
            + mediaItem.getContentUri() + " "
            + new File(mediaItem.getContentUri()).exists());

    // prepare file for upload
    PutObjectRequest putObjectRequest = new PutObjectRequest(
            awsMetadata.getBucketName(),
            awsMetadata.getSecretKey(),
            new File(mediaItem.getContentUri())
    );


    Log.d(App.TAG, "Total data: " + mediaItem.getSize());
    Upload upload = transferManager.upload(putObjectRequest, new S3ProgressListener() {

        private int totalTransfered = 0;

        @Override
        public void onPersistableTransfer(PersistableTransfer persistableTransfer) {
        }

        @Override
        public void progressChanged(ProgressEvent progressEvent) {

            Log.d(App.TAG, "Bytes are transferred: " + progressEvent.getBytesTransferred());
            totalTransfered += progressEvent.getBytesTransferred();
            long totalSize = mediaItem.getSize();
            Log.d(App.TAG, "Total transferred: " + ((totalTransfered / totalSize) * 100) + " percent");
        }
    });
}`

And got SSLException.

06-01 11:45:00.712 5182-5768/com.home I/AmazonHttpClient﹕ Unable to execute HTTP request: Write error: ssl=0xb4bb3600: I/O error during system call, Connection reset by peer javax.net.ssl.SSLException: Write error: ssl=0xb4bb3600: I/O error during system call, Connection reset by peer at com.android.org.conscrypt.NativeCrypto.SSL_write(Native Method) at com.android.org.conscrypt.OpenSSLSocketImpl$SSLOutputStream.write(OpenSSLSocketImpl.java:765) at com.android.okio.Okio$1.write(Okio.java:70) at com.android.okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:116) at com.android.okio.RealBufferedSink.write(RealBufferedSink.java:44) at com.android.okhttp.internal.http.HttpConnection$FixedLengthSink.write(HttpConnection.java:291) at com.android.okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:116) at com.android.okio.RealBufferedSink$1.write(RealBufferedSink.java:131) at com.amazonaws.http.UrlHttpClient.write(UrlHttpClient.java:155) at com.amazonaws.http.UrlHttpClient.createConnection(UrlHttpClient.java:143) at com.amazonaws.http.UrlHttpClient.execute(UrlHttpClient.java:60) at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:353) at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:196) at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4234) at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1644) at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadCallable.uploadInOneChunk(UploadCallable.java:134) at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadCallable.call(UploadCallable.java:126) at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadMonitor.upload(UploadMonitor.java:182) at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadMonitor.call(UploadMonitor.java:140) at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadMonitor.call(UploadMonitor.java:54) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:818)

Amazon SDK uses it's own client and it should be configured properly from the box.

What is the reason for this behaviour?

p.s.
I must note this application are developing in China, it means it uses "cn-north-1" region

Source code build error in android studio

Hello,

I am trying to build the source code available from here (https://github.com/aws/aws-sdk-android) rather than using jar files due to some reasons. I have added all the necessary third party libraries .

build.gradle

dependencies {
    compile files('libs/sjsxp.jar')
    compile files('libs/commons-codec-1.3.jar')
    compile files('libs/commons-logging-1.1.1.jar')
    compile files('libs/httpclient-4.2.3.jar')
    compile files('libs/httpcore-4.2.jar')
    compile files('libs/jackson-annotations-2.1.1.jar')
    compile files('libs/jackson-core-2.1.1.jar')
    compile files('libs/jackson-databind-2.1.1.jar')
    compile files('libs/joda-time-2.2.jar')
    compile files('libs/jaxp-api-1.4.2.jar')
}

When building the project, I got the following error:

/User/AndroidStudioProjects/AwsDemo/app/src/main/java/com/amazonaws/http/HttpClientFactory.java
Error:(101, 19) error: cannot find symbol method setRedirectStrategy(LocationHeaderNotRequiredRedirectStrategy)
Error:(108, 46) error: incompatible types: int cannot be converted to SocketFactory
Error:(110, 42) error: incompatible types: SSLContext cannot be converted to KeyStore
Error:(112, 48) error: incompatible types: int cannot be converted to SocketFactory
Error:(120, 42) error: incompatible types: int cannot be converted to SocketFactory
Error:(265, 39) error: constructor BasicScheme in class BasicScheme cannot be applied to given types;
required: no arguments
found: ChallengeState
reason: actual and formal argument lists differ in length
Error:(267, 51) error: cannot find symbol variable AUTH_CACHE
Error:(270, 51) error: cannot find symbol variable AUTH_CACHE
Error:(273, 67) error: cannot find symbol variable AUTH_CACHE
/User/AndroidStudioProjects/AwsDemo/app/src/main/java/com/amazonaws/metrics/MetricInputStreamEntity.java
Error:(46, 9) error: constructor InputStreamEntity in class InputStreamEntity cannot be applied to given types;
required: InputStream,long
found: InputStream,long,ContentType
reason: actual and formal argument lists differ in length

Also, latest aws sdk version is 2.1.7 but source code at github is 2.1.1 . Is it possible to get the latest aws android sdk source code ?

Dx Warnings

Dx warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.amazonaws.javax.xml.stream.xerces.util.SecuritySupport12$4) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is not an inner class.

Using non-latin app_title causes 403 error code

App title not handled correctly, f.e. App title "Список дел 1-3-5" in Russian become
"app_title":"!?8A>: 45; 1-3-5" in request header. It causes the following error:
Here is a stack trace:

09-18 13:47:18.044 2242-2515/com.appyfurious.todolist W/AmazonMobileAnalyticsSDK﹕ Unable to successfully deliver events to server. Events will be saved, error likely recoverable. Response status code 403 , response error code InvalidSignatureExceptionThe request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.
The Canonical String for this request should have been
'POST
/2014-06-05/events
content-length:4901
content-type:application/x-amz-json-1.0
host:mobileanalytics.us-east-1.amazonaws.com
user-agent:aws-sdk-android/2.1.0 Linux/3.1.10-g1e42d16 Dalvik/1.6.0/0 ru_RU com.amazonaws.mobileconnectors.amazonmobileanalytics.MobileAnalyticsManager/2.1.0
x-amz-client-context:{"client":{"client_id":"010cc368-5951-4ce1-837d-cd16e29dc114","app_title":"!?8A>: 45; 1-3-5","app_version_name":"1.0.2","app_version_code":"22","app_package_name":"com.appyfurious.todolist"},"custom":{},"env":{"platform":"ANDROID","carrier":"T-MOBILE PL","model":"Nexus 7","networkType":"WIFI","make":"asus","platform_version":"4.4.4","locale":"ru_RU"}}
x-amz-date:20140918T104716Z
...
x-amz-target:AmazonMobileAnalytics.PutEvents
x-amzn-clientsdkversion:AmazonMobileAnalyticsSDK-2.0.6
content-length;content-type;host;user-agent;x-amz-client-context;x-amz-date;x-amz-security-token;x-amz-target;x-amzn-clientsdkversion
cdc684cff6d8b5d1db20f0bcd9aa0666a2d83781b941497a89cba53a9f138300'
The String-to-Sign should have been
'AWS4-HMAC-SHA256
20140918T104716Z
20140918/us-east-1/mobileanalytics/aws4_request
803ac3a87ed5bf58d45a6964680ae7757cb7e47d74001813224f7daee6ee10ea'
(Service: AmazonMobileAnalytics; Status Code: 403; Error Code: InvalidSignatureException; Request ID: 2941b453-3f21-11e4-98ef-4f3c2020d29d)
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(Unknown Source)
at com.amazonaws.http.AmazonHttpClient.executeHelper(Unknown Source)
at com.amazonaws.http.AmazonHttpClient.execute(Unknown Source)
at com.amazonaws.services.mobileanalytics.AmazonMobileAnalyticsClient.invoke(Unknown Source)
at com.amazonaws.services.mobileanalytics.AmazonMobileAnalyticsClient.putEvents(Unknown Source)
at com.amazonaws.mobileconnectors.amazonmobileanalytics.internal.delivery.DefaultDeliveryClient.submitEvents(Unknown Source)
at com.amazonaws.mobileconnectors.amazonmobileanalytics.internal.delivery.DefaultDeliveryClient.access$600(Unknown Source)
at com.amazonaws.mobileconnectors.amazonmobileanalytics.internal.delivery.DefaultDeliveryClient$3.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)

Authentication resets after restart when using developer auth provider

We're currently trying to integrate Cognito using developer authenticated identities using the following example:
https://mobile.awsblog.com/post/Tx3E3NJURV1LNV1/Integrating-Amazon-Cognito-using-developer-authenticated-identities-An-end-to-en

We can successfully receive data from Cognito after authentication, but the problem is that when we restart the application, SDK resets the identity to null for some reason and we need to perform authentication process once again (add an entry to logins hashmap, request token, etc).

It seems like sdk has correct sessionCredentials during the same launch when authentication happened, but loses them on restart. saveCredentials method in CognitoCachingCredentialsProvider is not being called, so I assume credentials are not cached or something like that. I don't know if sessionCredentials are to be obtained from SharedPreferences at all times so I'm not sure this is what causes the problem.

We have tried to use developer authenticated identities in CognitoSyncDemo project from aws-sdk-android-samples and it behaves the same way when implemented there.

Thanks!

Connect with Amazon using IP instead of Address

Is it possible to connect to Amazon using fixed IP instead address?

We are working on a device which uses android and has a mobile GPRS modem (Sierra or Gemalto) and using SQS and S3 APIs to communicate with Amazon. When we use the wifi it works fine, but when we use the GPRS modem we get issues with DNS resolving.

Is there any way we can fix the IP for S3 and SQS we want to communicate?
Thanks

SSLException: hostname in certificate didn't match

Hi,

I'm testing newest release 2.1.2, and when trying to upload file to S3, I got this exception:

javax.net.ssl.SSLException: hostname in certificate didn't match: <com.myappname.debug.s3.amazonaws.com> != <*.s3.amazonaws.com> OR <*.s3.amazonaws.com> OR <s3.amazonaws.com>

It worked in 2.1.1. Pls let me know if you need more detail, thanks

Reduce dependency on huge libraries

Hi,

Android has the weird limitation that they only allow 64K methods on an apk. This SDK already uses too many methods because the third party libraries (apache common, jackson, joda time) are huge, so when I compile a normal app, I will get this error:

Unable to execute dex: method ID not in [0, 0xffff]: 65536
Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536

Since you are rewriting the SDK, is it possible to eliminate dependencies on these libraries? I know for date time, date4j is pretty good replacement with tiny size compared to Joda, and very easy to migrate to it. I hope there's alternative to apache common too, that library is huge but not always useful to be included.

Upload Pdf/word file to s3 server

Hi i am using aws android sdk for uploading images to my bucket on the server it is running fine, but How can we upload Pdf/word files to my bucket , please anyone guide me with demo ?

Service: AWSSecurityTokenService; Status Code: 403; Error Code: AccessDenied; Request ID: 83bfc431-3733-11e4-90c0-6dbe37b9d930)

Hello,

I am uploading photo on s3 amazon using provided demo code. and used v2 library. But while selecting photo application goes force close. and i got below error.

java.lang.RuntimeException: Unable to create service com.amazonaws.demo.s3_transfer_manager.network.NetworkService: com.amazonaws.AmazonServiceException: Not authorized to perform sts:AssumeRoleWithWebIdentity (Service: AWSSecurityTokenService; Status Code: 403; Error Code: AccessDenied; Request ID: 83bfc431-3733-11e4-90c0-6dbe37b9d930)

How to solve this..!

Thanks

Looper not initialized in new S3 TransferUtility

Hi there,

Overall the new S3 Transfer Utility seems great!
I'm currently trying to upgrade our application to make use of the new API, but it seems the threading was not correctly implemented. I'm getting the following error when I try to upload a file :
Can't create handler inside thread that has not called Looper.prepare()

It comes from the Handler() creation here :
https://github.com/aws/aws-sdk-android/blob/master/aws-android-sdk-s3/src/main/java/com/amazonaws/mobileconnectors/s3/transferutility/TransferObserver.java#L161

Stacktrace :

android.os.Handler.<init>(Handler.java:197)
android.os.Handler.<init>(Handler.java:111)
com.amazonaws.mobileconnectors.s3.transferutility.TransferObserver$TransferContentObserver.<init>(TransferObserver.java:161)
com.amazonaws.mobileconnectors.s3.transferutility.TransferObserver.<init>(TransferObserver.java:66)
com.amazonaws.mobileconnectors.s3.transferutility.TransferUtility.upload(TransferUtility.java:161)
com.neurodesign.utils.amazonws.AWSBridge.asyncS3Upload(AWSBridge.java:158)
com.neurodesign.utils.amazonws.AWSBridge.s3Upload(AWSBridge.java:132)
com.neurodesign.utils.s3PhotoUploader.S3PhotoUploadJob.onRun(S3PhotoUploadJob.java:74)
com.path.android.jobqueue.Job.safeRun(Job.java:189)
com.path.android.jobqueue.JobHolder.safeRun(JobHolder.java:91)
com.path.android.jobqueue.executor.JobConsumerExecutor$JobConsumer.run(JobConsumerExecutor.java:306)
java.lang.Thread.run(Thread.java:856)

AmazonClientException Input stream exceeds 256k buffer

Using Android Aws sdk 2.2.1 I am seeing a few occurrence of this exception (Only on Android 5.0 and 5.1.1 so far):

com.amazonaws.AmazonClientException: Input stream exceeds 256k buffer.
       at com.amazonaws.services.s3.AmazonS3Client.toByteArray(AmazonS3Client.java:4378)
       at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1581)
       at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadCallable.uploadInOneChunk(UploadCallable.java:134)
       at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadCallable.call(UploadCallable.java:126)
       at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadMonitor.upload(UploadMonitor.java:182)
       at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadMonitor.call(UploadMonitor.java:140)
       at com.amazonaws.mobileconnectors.s3.transfermanager.internal.UploadMonitor.call(UploadMonitor.java:54)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
       at java.lang.Thread.run(Thread.java:818)

Can you guys clarify what's going on?

Upload does not resume using aws-android-sdk-2.2.3-s3

Hi there,

For Low level api:
I am using low level api for multipart upload .When i kill the app and try to resume upload it doesnot resume instead it restarts .When i try resume the upload i am getting different upload id for same key and bucket.
When tried to store the upload id obtain when i start upload and try to used that upload id first time upload resumed but it did not complete.I got following error exception:
06-11 16:55:51.374 22136-22388/com.sharez D/UploadObjectMPU﹕ Error !!! :: One or more of the specified parts could not be found. The part may not have been uploaded, or the specified entity tag may not match the part's entity tag. (Service: Amazon S3; Status Code: 400; Error Code: InvalidPart; Request ID: 264F4CFFAE836648)

Second time:
Upload did not resume and i got following error:
06-12 11:09:39.108 7160-7222/com.sharez D/UploadObjectMPU﹕ Error !!! :: The specified upload does not exist. The upload ID may be invalid, or the upload may have been aborted or completed. (Service: Amazon S3; Status Code: 404; Error Code: NoSuchUpload; Request ID: AAD7BBFAB6F5402B)

.Following is the code used.

/**
* This method is useful to resume update
*
* @param pInitResponse
* @param pS3Client
* @param pPartETags
* @return
*/
private int retrievePartDetails(
InitiateMultipartUploadResult pInitResponse,
AmazonS3Client pS3Client, List pPartETags) {
// for new upload this upload id may be null or empty for paused upload
// this has some values
String lUploadId =pInitResponse.getUploadId();
Log.d(TAG, "retrievePartDetails(): uploadId = " + lUploadId);
ListPartsRequest lPartsRequest = new ListPartsRequest(mBucketName,
mKeyName, lUploadId);
PartListing lListing = pS3Client.listParts(lPartsRequest);
List lList = lListing.getParts();

    for (PartSummary lPartSummary : lList) {
        PartETag lPartETag = new PartETag(lPartSummary.getPartNumber(),
                lPartSummary.getETag());
        pPartETags.add(lPartETag);
    }

    return (lList.size() < 1) ? 1 : lList.get(lList.size() - 1)
            .getPartNumber() + 1;
}

/**
* get a upload request
*

 * 
 * @return
 */

private InitiateMultipartUploadRequest getUploadRequest() {

    return new InitiateMultipartUploadRequest(mBucketName, mKeyName);
    // return new InitiateMultipartUploadRequest(mBucketName, mKeyName);
}


/**
 * Intiate mutipart request
 * 
 * @param pS3LowLevelUploadTask
 * @param pFile
 */

private void initateMutipartRequest(
S3LowLevelUploadTask pS3LowLevelUploadTask, File pFile) {
// Create a list of UploadPartResponse objects. You get one of these
// for each part upload.
List lPartETags = new ArrayList();
try {

        mInitResponse = mS3Client
                .initiateMultipartUpload(getUploadRequest());

        // required for resume
        int lStartPart = retrievePartDetails(mInitResponse, mS3Client,
                lPartETags);
        Log.d(TAG, "lStartPart = " + lStartPart);

        long lFilePosition = (lStartPart - 1) * mPartSize;
        Log.d(TAG, "filePosition = " + lFilePosition);
        // show default progress for multipart upload


        for (int i = lStartPart; lFilePosition < mFileSize; i++) {


            // Last part can be less than 5 MB. Adjust part size.
            mPartSize = Math.min(mPartSize, (mFileSize - lFilePosition));

            // Create request to upload a part.
            mUploadRequest = new UploadPartRequest()
                    .withBucketName(mBucketName).withKey(mKeyName)
                    .withUploadId(mInitResponse.getUploadId())
                    .withPartNumber(i).withFileOffset(lFilePosition)
                    .withFile(pFile).withPartSize(mPartSize)
                    .withGeneralProgressListener(this);

            // Upload part and add response to our list.
            lPartETags.add(mS3Client.uploadPart(mUploadRequest)
                    .getPartETag());
            lFilePosition += mPartSize;
            // request update percentage to UI

            pS3LowLevelUploadTask.updateProgress(getPercentageUpload(
                    mFileSize, lFilePosition));
            Log.d(TAG, "filePosition = " + lFilePosition);

        }





            perfromComplete(mInitResponse, lPartETags, mS3Client);





    } catch (AbortedException lAse) {
        lAse.printStackTrace();
    } catch (Exception e) {
        Log.d(TAG, "Error !!! :: " + e.getMessage());
        e.printStackTrace();

    }

}

/**
* Mark file has been successfully uploaded
*
* @param pInitResponse
* @param pPartETags
* @param pS3Client
* @param pS3LowLevelUploadTask
*/
private void perfromComplete(InitiateMultipartUploadResult pInitResponse,
List pPartETags, AmazonS3Client pS3Client) {
CompleteMultipartUploadRequest compRequest = new CompleteMultipartUploadRequest(
mBucketName, mKeyName, pInitResponse.getUploadId(), pPartETags);
pS3Client.completeMultipartUpload(compRequest);

}

For high level api:

/*To save transfer state/
public void saveTransferState(PersistableTransfer persistableTransfer, String fileName) {
// Create a new file to store the information.
File f = new File(fileName);
if( !f.exists() ) f.createNewFile();
FileOutputStream fos = new FileOutputStream(f);
// Serialize the persistable transfer to the file.
persistableTransfer.serialize(fos);
fos.close();
}

PutObjectRequest putRequest = new PutObjectRequest(BUCKET_NAME, mKey,file);
// Upload a file to Amazon S3.
transferManager.upload(putRequest, new S3ProgressListener() {
ExecutorService executor = Executors.newFixedThreadPool(1);
@OverRide
public void onPersistableTransfer(final PersistableTransfer persistableTransfer) {
executor.submit(new Runnable() {
@OverRide
public void run() {
saveTransferState(persistableTransfer, “resume-upload”);
}
});
}
});

For resuming upload:

String fileName = "resume-upload";
File f = new File (fileName);
if(f.exists()) {
FileInputStream fis = new FileInputStream(f);
// Deserialize PersistableUpload information from disk.
PersistableUpload persistableUpload = PersistableTransfer.deserializeFrom(fis);
// Call resumeUpload with PersistableUpload.
mUpload = transferManager.resumeUpload(persistableUpload);
try {

        if (mUpload != null) {

            mUpload.addProgressListener(this);

            mUpload.waitForCompletion();

        }
    }

    catch (AmazonServiceException e) {

        e.printStackTrace();

    } catch (AmazonClientException e) {

        e.printStackTrace();

    } catch (InterruptedException e) {

        e.printStackTrace();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

fis.close();
}

Android resource not found issue

Hi,
I have an issue in my android project.when i use your this jar for some timezone.please help me what is this issue.

E/AndroidRuntime(3028): FATAL EXCEPTION: AsyncTask #1
10-14 12:16:28.232: E/AndroidRuntime(3028): java.io.IOException: Resource not found: "org/joda/time/tz/data/ZoneInfoMap" ClassLoader: dalvik.system.DexClassLoader[DexPathList[[zip file "/data/data/com.xxx.xxx/files/dlibs/libs-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.xxx.xxx-1, /vendor/lib, /system/lib]]]
10-14 12:16:28.232: E/AndroidRuntime(3028): at org.joda.time.tz.ZoneInfoProvider.openResource(ZoneInfoProvider.java:211)
10-14 12:16:28.232: E/AndroidRuntime(3028): at org.joda.time.tz.ZoneInfoProvider.(ZoneInfoProvider.java:123)
10-14 12:16:28.232: E/AndroidRuntime(3028): at org.joda.time.tz.ZoneInfoProvider.(ZoneInfoProvider.java:82)
10-14 12:16:28.232: E/AndroidRuntime(3028): at org.joda.time.DateTimeZone.getDefaultProvider(DateTimeZone.java:462)
10-14 12:16:28.232: E/AndroidRuntime(3028): at org.joda.time.DateTimeZone.setProvider0(DateTimeZone.java:416)
10-14 12:16:28.232: E/AndroidRuntime(3028): at org.joda.time.DateTimeZone.(DateTimeZone.java:115)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.amazonaws.util.DateUtils.(Unknown Source)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.amazonaws.services.s3.internal.ServiceUtils.(Unknown Source)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.amazonaws.services.s3.internal.S3Signer.sign(Unknown Source)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.amazonaws.http.AmazonHttpClient.executeHelper(Unknown Source)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.amazonaws.http.AmazonHttpClient.execute(Unknown Source)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.amazonaws.services.s3.AmazonS3Client.invoke(Unknown Source)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.amazonaws.services.s3.AmazonS3Client.createBucket(Unknown Source)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.amazonaws.services.s3.AmazonS3Client.createBucket(Unknown Source)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.xxx.xxx.presentations.data.AmazonFileUploader.uploadPdf(AmazonFileUploader.java:37)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.xxx.xxx.xxx.xxx.dialogs.PdfViewerDialog$savePresentationTask.doInBackground(PdfViewerDialog.java:143)
10-14 12:16:28.232: E/AndroidRuntime(3028): at com.xxx.xxx.presentations.fragments.dialogs.PdfViewerDialog$savePresentationTask.doInBackground(PdfViewerDialog.java:129)
10-14 12:16:28.232: E/AndroidRuntime(3028): at android.os.AsyncTask$2.call(AsyncTask.java:287)
10-14 12:16:28.232: E/AndroidRuntime(3028): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
10-14 12:16:28.232: E/AndroidRuntime(3028): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
10-14 12:16:28.232: E/AndroidRuntime(3028): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
10-14 12:16:28.232: E/AndroidRuntime(3028): at java.lang.Thread.run(Thread.java:841)

Video uploading taken lots of time instead of ios

We are using video uploading functionality in android and ios.
Both have same function for uploading but in android it taken more time compare to ios
and that is meaning less.
Can you please any solution for this issue ?

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.