microsoftgraph / msgraph-sdk-android

Microsoft Graph SDK for Android! https://graph.microsoft.io
Other
51 stars 43 forks source link

Use ChunkedUploadProvider asynchronously #70

Closed NLLAPPS closed 4 years ago

NLLAPPS commented 6 years ago

Hi, is there any sample for uploading large files? There is this sample

client.getMe() .getDrive() .getRoot() .getItemWithPath("me.png") .getContent() .buildRequest() .put(file, callback);

As you would imagine, it would be trouble some to put large files. How would one achieve that? Thanks.

caitlinrussell commented 6 years ago

To accomplish this, you will want to use Resumable Upload. There is currently no example in the SDK, but you will want to use createUploadSession on your item and create a new ChunkedUploadProvider to process your request in chunks.

caitlinrussell commented 6 years ago

In pseudocode:

DriveItemUploadableProperties props = new DriveItemUploadableProperties();
// Set file name, size, etc.
client.getMe().getDrive().getRoot().getItemWithPath("me.png").createUploadSession(props).buildRequest().post();

ChunkedUploadProvider provider = new ChunkedUploadProvider<T>(session, client, stream, size, class);
provider.upload(options, callback, configs);
NLLAPPS commented 6 years ago

Thank you. I'll try. While ı have you, there seems to be a lot of different ads related to OneDrive and authentication.

As I understand from what I have read so far it they graph sdk is the way forward. Is that correct?

caitlinrussell commented 6 years ago

Yes, that is what we are recommending. However, we are not yet at full parity with Azure AD, so I would verify in the Graph docs that your scenarios are supported. We should be near or at parity with OneDrive.

MIchaelMainer commented 6 years ago

@NLLAPPS In case it helps, here's the commit in the .Net client library where we implemented large file uploads. https://github.com/microsoftgraph/msgraph-sdk-dotnet/commit/7c037cf15413b73d1ad7b52ee027a703f4b63be1#diff-374daffefc443a2b383da1d332b730c6

NLLAPPS commented 6 years ago

Cheers, it should not be too card to convert

On 7 December 2017 17:52:27 GMT+00:00, "Caitlin Bales (MSFT)" notifications@github.com wrote:

Yes, that is what we are recommending. However, we are not yet at full parity with Azure AD, so I would verify in the Graph docs that your scenarios are supported.

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/microsoftgraph/msgraph-sdk-android/issues/70#issuecomment-350044326

NLLAPPS commented 6 years ago

Hi guys, I am not sure if I am doing this right. ChunkedUploadProvider.upload is a blocking method that runs on main thread with callback.

How would one use an AsyncTask or another thread while waiting for the call back. The only way I can think of is to block the AysncTask with another variable within the task that changes according to IProgressCallback result.

Wouldn't it be simpler if ChunkedUploadProvider.upload done on another thread?

NLLAPPS commented 6 years ago

Any feedback about the above issue?

NLLAPPS commented 6 years ago

Anyone? @cbales @MIchaelMainer

ronnafaye commented 6 years ago

Hi @cbales , I was able to create ChunkedUploadProvider but I'm having error when I tried the upload function. May I know what is the int configs parameter? Maybe you can provide a sample snippet of this function. Your help is much appreciated. @_@

kbboss commented 6 years ago

@PAYong finally,how you make it work? about uploading large file with microsoft api. I got the same problem

NLLAPPS commented 5 years ago

Any updates to this issue?

ohs0612 commented 5 years ago

I would like to know how to upload file by using CreateUploadSession from msgraph-sdk-android OneDrive SDK.

baywet commented 4 years ago

Hi everyone, Thank you for the contribution, we have moved away from an android specific SDK to a Java SDK and this repo will be archived very soon. If you're still facing the same issue with the Java SDK, feel free to re-open an issue over there. Closing.