Obtaining the uploaded file from the SFUploadRunnable in the Java SDK

  • 1
  • Question
  • Updated 2 weeks ago
I am using the Java SDK as described here: https://github.com/citrix/ShareFile-Java to upload files to a ShareFile-folder. It works, but I cannot figure out how to obtain the uploaded file or Id. I only see the onComplete-method with the bytesTransferred. What would be the Java-equivalent of the .NET  var uploadResponse = await uploader.UploadAsync();?
Photo of Øystein Molnes

Øystein Molnes

  • 5 Posts
  • 0 Reply Likes

Posted 3 weeks ago

  • 1
Photo of Ross Bender

Ross Bender

  • 57 Posts
  • 9 Reply Likes
I believe you'll need to use the Threaded Uploader:

If using the Threaded Uploader, the client can add the parameter fmt=json to the ChunkUri to retrieve the Item ID of the file after the upload is completed.

https://api.sharefile.com/rest/docs/resource.aspx?name=Items
Photo of Øystein Molnes

Øystein Molnes

  • 5 Posts
  • 0 Reply Likes
Thank you for replying. Does the Java SDK offer a threaded uploader, or will I have to use the API directly in order to obtain the id of the uploaded file? I have tried that and it works, but I am looking for a way to do the same thing with the Java  SDK.
Photo of Nilesh Pawar

Nilesh Pawar

  • 10 Posts
  • 1 Reply Like
@Øystein Molnes  Which version of the Java SDK you are using?  The SDK has long been updated to support the itemId being returned in the progresslistener callback :

https://github.com/citrix/ShareFile-Java/blob/master/ShareFileJavaSDK/src/com/citrix/sharefile/api/h...

public void onComplete(long bytesTransfered, String itemId);  
Photo of Øystein Molnes

Øystein Molnes

  • 5 Posts
  • 0 Reply Likes
I was using version 3.1.2, but after updating to version 3.1.5 I am now able to use the onComplete with itemId. Thank you.