I've read as much as I can here on this topic and I've crawled through the documentation (AWS 2.2.9) and am using their example code as closely as I can and I'm stuck. Here's what I've done for setup:
Manifest -
relevant permissions - "android.permission.INTERNET" and "android.permission.ACCESS_NETWORK_STATE"
service -
android:name= "com.amazonaws.mobileconnectors.s3.transferutility.TransferService" android:enabled="true"
I have my bucket set up and also credentials for Cognito. Here is the code I've added for doing the upload:
File f = getVideoFile(activity);
...
TransferObserver observer = sTransferUtility.upload(Constants.BUCKET_NAME, f.getName(), f);
observer.setTransferListener(new TransferListener() {
@Override
public void onProgressChanged(int id, long bytesCurrent, long bytesTotal) {
Log.e("Transfer", "Percent Complete = " + bytesCurrent / bytesTotal * 100);
}
@Override
public void onStateChanged(int id, TransferState state) {
Log.e("Transfer", "onStateChanged");
Log.e("Transfer", "state = " + state);
}
@Override
public void onError(int id, Exception ex) {
Log.e("Transfer", "Error = " + ex.getMessage());
}
});
I've also temporarily added a wait loop after to see if I'm just being impatient but it just shows state = WAITING until I kill the app:
TransferState state = observer.getState();
while (state != TransferState.COMPLETED) {
Log.e("Transfer", "state = " + state);
try {
Thread.sleep(10000);
state = observer.getState();
} catch (Exception e) {
Log.e("Transfer", "exception " + e.getMessage());
}
}
All of this is happening inside a fragment. I see no errors being reported (I understand that others have observed that missing configuration can result in this behavior but I think I've done everything I am supposed to do, here).
I would be grateful to hear of anything I've overlooked or need to try to get further information.
Edit:
I am not suspicious that the whole problem is not with the code but rather with the configuration that I've got.
My Cognito and bucket Id look like the following (but aren't exactly these):
COGNITO_POOL_ID: "us-east-1:abcdefgh-abcd-efgh-ijkl-mnopqrstuvwxy" BUCKET_NAME: "MyBucket"
I am also curious as to whether the key should be the file name in my .upload() should include the path or just the filename. I've tried both but which of these would be correct:
/storage/emulated/0/Android/data/com.blah.blah/files/video.mp4
or
video.mp4
Good so far?
Thanks.
-VAR