question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Re-Used Notification When Uploading Same File Twice Or More at the same time

See original GitHub issue

Version info

  • Android Upload Service version: 3.0.3
  • Android version and API version: any
  • HTTP stack (e.g. HurlStack or OkHttpStack): HurlStack

What did you expect?

Seperate notification

What happened instead?

Re-used notification

Steps to reproduce (if applicable):

I have the same file uploaded twice or more at the same time. The notification from that different uploads will use the same notification.

Library initialization code:

UploadService.NAMESPACE = BuildConfig.APPLICATION_ID;

Request code:

final MultipartUploadRequest multipartUploadRequest = new MultipartUploadRequest(this, mCurrentPhotoPath, url)
.setNotificationConfig(getNotificationConfig(mCurrentPhotoPath))
.setMaxRetries(0);
multipartUploadRequest.addFileToUpload(uriToUpload.getPath(), "file");
multipartUploadRequest.addParameter("some param key", "value");
multipartUploadRequest.addHeader("some cookie key", "value");
multipartUploadRequest.startUpload();

Where have you added the request code?

  • Activity
  • Service
  • Other class (add additional info about it)

Additional info

Basically the code in the Request code section above, called twice or more in a short time with the same file.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
gotevcommented, Jan 6, 2017

@hendrawd you have explained your scenario well even in the previous post. What I suggest you to do in your case is simply:

String uploadId = UUID.randomUUID().toString();

MultipartUploadRequest req = new MultipartUploadRequest(this, uploadId, url);

The id which you will get from:

String id = req.startUpload();

in this case is the same uploadId you have passed in the constructor, so you know the id even before the startUpload method invocation, because you generated it. Scenario like yours are exactly the reason why I’ve implemented also the constructor in which you can pass your own uploadId.

Some reference: MultipartUploadRequest constructor | startUpload method

0reactions
hendrawdcommented, Jan 6, 2017

Yes, i know. Sorry i wasn’t really clear from my last post. I edited your library to use notification action button #181 because of my requirement. The button just simply a cancel action.

I can create NotificationAction by:

NotificationAction actionCancel = new NotificationAction(R.drawable.ic_close, getString(R.string.notification_active_action_cancel_upload), UploadCanceller.getPendingIntent(this, uploadId));

Then i set it to NotificationConfig

private UploadNotificationConfig getNotificationConfig(String uploadId) {
    return new UploadNotificationConfig().addAction(actionCancel);//i set other configs too
}

Then i set it to MultipartUploadRequest

multipartUploadRequest.setNotificationConfig(getNotificationConfig(mCurrentPhotoPath));

I can’t get the id before i call

String idNeeded = multipartUploadRequest.startUpload();

But i must set the canceller with ID before call startUpload, that’s why i create the ID directly

Read more comments on GitHub >

github_iconTop Results From Across the Web

Filereader - upload same file again not working - Stack Overflow
If you upload the same file the value of the file input has not changed from the previous upload and therefore isn't triggered....
Read more >
How to stop sharepoint from uploading the same file again ...
Asks me if I want to replace the existing file. 3. Then uploads the entire file again. Is there a way to make...
Read more >
[BUG] dcc.Upload does not support re-upload the same file.
It appears that if one uses the dcc.Upload.contents property for triggering callback, it fails when the user tries to upload the same file...
Read more >
Box File Request FAQ - Box Support
Can someone upload the same file twice in an upload zone? No. It's not possible to upload the same file more than once...
Read more >
A strategy for handling multiple file uploads using JavaScript
So, you need to get files from your user's browser to your server. Not just one file though. A whole bunch. A batch...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found