-
Notifications
You must be signed in to change notification settings - Fork 549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File upload fails with no error on 2.2.11 #93
Comments
Thanks for reporting. I've identified the bug. The listener is garbage collected before the transfer finishes. I am working on the fix. A temporary workaround at the moment is to make the listener live longer, e.g. make it a class member of the containing activity/fragment, or have the container implements the listener. Stay tuned for the fix. |
Actually this is a design change that isn't disclosed clearly in the change log. Previously, a listener is attached as a content observer. Like all other content observers, they must be unregistered when no longer needed, or else it will cause memory leak. The following is a very typical usage of TransferUtility: public class MainActivity extends Activity {
// set up in onCreate()
private TransferUtility transferUtility;
private AmazonS3 s3;
// upload a file
private void upload() {
TransferObserver transfer = transferUtility.upload(bucket, key, file);
transfer.setTransferListener(new TransferListener() {
// implement listener
});
}
} Here the transfer listener is an anonymous class defined inside an activity. Thus it has an implicit reference of the activity. If it is not unregistered via We notice it's inconvenient to clear the listener. One has to save a reference of the transfer and then clear it inside public class MainActivity extends Activity {
// set up in onCreate()
private TransferUtility transferUtility;
private AmazonS3 s3;
private TransferListener listener;
@Override
protected void onCreated() {
listener = new TransferListener() {
@Override
public void onProgressChanged(int id, long bytesCurrent, long bytesTotal) {
// update progress listener
}
}
}
// upload a file
private void upload() {
TransferObserver transfer = transferUtility.upload(bucket, key, file);
transfer.setTransferListener(listener);
}
} |
I need to pass parameter in Transferlisterner for updating progress through progress bar So I have to create listener when need to upload video. so according your suggestion create listener in OnCreate method not work for me. Could you provide me some reliable solution for this issue? |
I am using an Intent Service to upload in background and i need to pass some arguments on changing the status to COMPLETE, But facing the above said issue with sdk version 2.2.12. Please suggest a solution. |
This is improved in v2.2.13 release. Please update the SDK at https://aws.amazon.com/mobile/sdk/. Check out what is changed in the change log. |
Closing this as it's improved in v2.2.13. Feel free to reopen it. |
Hi,
It seems that there is a random bug that makes the file upload fail for no reason.
Here is the piece of code i have :
This is supposed to upload a video file to amazon servers.
It worked until v2.2.11.
For no reason, it happens that onProgressChanged() is called only once or twice, then nothing is happening. Same for onStateChanged(). It is called only once (when the upload starts).
onError() is never called. The upload process just stop.
Here is the log
We can see the transfer starts (IN_PROGRESS state), a piece of data is sent then nothing is happening. We receive a response from Amazon server then nothing, the service stops itself.
This piece of code works perfectly on v2.2.10, transfer works everytime so it's not a internet issue or an amazon servers issue
The text was updated successfully, but these errors were encountered: