Skip to content

Commit b474d87

Browse files
author
SDS
committed
Updated to AWS version to 2.16.4 to deal with special chars issue in file key name issue.
1 parent 0c6676b commit b474d87

File tree

3 files changed

+37
-22
lines changed

3 files changed

+37
-22
lines changed

android/build.gradle

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,25 @@ repositories {
7878
}
7979
}
8080

81+
8182
dependencies {
8283
//compile 'com.facebook.react:react-native:+'
8384
compile('com.facebook.react:react-native:0.61.4') { force = true }
8485

8586
// compile 'com.amazonaws:aws-android-sdk-core:2.3.+'
8687
// compile 'com.amazonaws:aws-android-sdk-cognito:2.3.+'
8788
// compile 'com.amazonaws:aws-android-sdk-s3:2.3.+'
88-
compile 'com.amazonaws:aws-android-sdk-core:2.6.30'
89-
compile 'com.amazonaws:aws-android-sdk-cognito:2.6.30'
90-
compile 'com.amazonaws:aws-android-sdk-s3:2.6.30'
91-
// compile 'com.amazonaws:aws-android-sdk-core:2.13.4'
92-
// compile 'com.amazonaws:aws-android-sdk-cognito:2.13.4'
93-
// compile 'com.amazonaws:aws-android-sdk-s3:2.13.4'
89+
90+
//WORKS
91+
// compile 'com.amazonaws:aws-android-sdk-core:2.6.30'
92+
// compile 'com.amazonaws:aws-android-sdk-cognito:2.6.30'
93+
// compile 'com.amazonaws:aws-android-sdk-s3:2.6.30'
94+
95+
// Updated to handle special chars issue in file key name
96+
compile 'com.amazonaws:aws-android-sdk-core:2.16.4'
97+
compile 'com.amazonaws:aws-android-sdk-cognito:2.16.4'
98+
compile 'com.amazonaws:aws-android-sdk-s3:2.16.4'
99+
compile 'com.amazonaws:aws-android-sdk-mobile-client:2.16.4'
94100

95101
}
96102
allprojects {

android/src/main/java/com/mybigday/rns3/RNS3TransferUtility.java

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
import com.facebook.react.bridge.Promise;
2626

2727
import com.amazonaws.services.s3.*;
28+
// Updated to handle special chars issue in file key name
29+
import com.amazonaws.mobile.client.AWSMobileClient;
2830
import com.amazonaws.mobileconnectors.s3.transferutility.*;
31+
2932
import com.facebook.react.bridge.ReadableMap;
3033
import com.facebook.react.bridge.ReadableMapKeySetIterator;
3134
import com.facebook.react.bridge.WritableArray;
@@ -101,8 +104,17 @@ public void onStateChanged(int id, TransferState state) {
101104

102105
@Override
103106
public void onProgressChanged(int id, long bytesCurrent, long bytesTotal) {
104-
System.out.println("TASK ID:" + id);
107+
//System.out.println("TASK ID:" + id);
105108
TransferObserver task = transferUtility.getTransferById(id);
109+
110+
// Updated to handle special chars issue in file key name
111+
// Added Null Check to prevent
112+
// AndroidRuntime: java.lang.NullPointerException: Attempt to invoke
113+
// virtual method 'com.amazonaws.mobileconnectors.s3.transferutility.TransferState
114+
// com.amazonaws.mobileconnectors.s3.transferutility.TransferObserver.getState()' on a null object reference
115+
if (task == null) {
116+
return;
117+
}
106118
if (task.getState().toString().equals("IN_PROGRESS") && !enabledProgress) {
107119
return;
108120
}
@@ -180,19 +192,9 @@ private boolean setup(Map<String, Object> credentialsOptions) {
180192
default:
181193
return false;
182194
}
183-
// TODO: TransferNetworkLossHandler
184-
// TransferNetworkLossHandler.getInstance(context);
185-
//TODO
186-
// TransferUtility transferUtility =
187-
// TransferUtility.builder()
188-
// .context(context.getApplicationContext())
189-
// .awsConfiguration(AWSMobileClient.getInstance().getConfiguration())
190-
// .s3Client(new AmazonS3Client(AWSMobileClient.getInstance()))
191-
// .build();
192-
193-
// BasicAWSCredentials creds = new BasicAWSCredentials("access_key", "secret_key");
194-
// AmazonS3 s3Client = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(creds)).build();
195-
//TODO
195+
196+
// Updated to handle special chars issue in file key name
197+
TransferNetworkLossHandler.getInstance(context);
196198

197199
// TODO: support ClientConfiguration
198200
if (credentials != null) {
@@ -201,7 +203,14 @@ private boolean setup(Map<String, Object> credentialsOptions) {
201203
s3 = new AmazonS3Client(credentialsProvider);
202204
}
203205
s3.setRegion(region);
204-
transferUtility = new TransferUtility(s3, context);
206+
//transferUtility = new TransferUtility(s3, context);
207+
208+
transferUtility = TransferUtility.builder()
209+
.context(context)
210+
.awsConfiguration(AWSMobileClient.getInstance().getConfiguration())
211+
.s3Client(s3)
212+
.build();
213+
205214
return true;
206215
}
207216

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-s3",
3-
"version": "0.0.30",
3+
"version": "0.0.31",
44
"description": "A React Native wrapper for AWS S3 SDK",
55
"main": "./src/index.js",
66
"files": ["android/", "ios/", "src/"],

0 commit comments

Comments
 (0)