Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

upload_async returns UploadSession #122

Closed
Kansattica opened this issue Jan 31, 2018 · 9 comments
Closed

upload_async returns UploadSession #122

Kansattica opened this issue Jan 31, 2018 · 9 comments

Comments

@Kansattica
Copy link

I am trying to upload a large (~500 MB) file to OneDrive, and after reading some of the issues (#74, #103, #104), I learned that upload_async was the way to go, so I have this line:

returned_item = client.item(drive='me', path='root').upload_async('./downloaded/' + newname)

However, returned_item is of the type onedrivesdk.model.upload_session.UploadSession, and not Item like upload() does. According to the answer for issue #51, this should work, but I don't know if this is a bug or if I'm using the code wrong. I haven't been able to find any documentation on this UploadSession business.

I'm running version 1.1.8 of the SDK, and this happens with both Python 3.6.3 and 3.5.3.

@Kansattica
Copy link
Author

Never mind, this worked- I just had to call to_dict() on the upload session. The thing actually was getting uploaded.

@schvarcz
Copy link

Hello.

I am experiencing the same problem here when trying to upload large files. Could you detail how do you use to_dict() to workaround the issue?

Moreover, I have been searching in the repository to understand why this issue is happening. I found out that the problem is in this file. More precisely, function fragment_upload_async.

The same function is returning two different type of objects according to the filesize. An Item if the file is smaller than 10mb or an UploadSession if it is bigger.

Even though it is possible in python, I don't believe it is a clever design since it would cause this kind of misinformation. If it was suppose to be like that, at least the function documentation have to be updated.

Could you reopen this issue in order to open this discussion again?

Thank you in advance.

@Kansattica
Copy link
Author

It's been a while since I worked on the code, but if I want to upload a large (much larger than 10MB) file to OneDrive, that code looks like this:

returned_item = client.item(drive='me',id=item.parent_reference.id).children[newname].upload_async('./downloaded/' + newname).to_dict()

I suspect this makes the would-be async upload block until it's done, and maybe if you wait around long enough the upload will finish without you having to call to_dict()?

Hope this helps!

@Kansattica Kansattica reopened this Jun 23, 2018
@jackshifter
Copy link

Hi..Adding to_dict() at the end of upload_async is not working for me. Gives an error upload async has no method to_dict().
When I dont use to_dict(), there is no error.. Code runs successfully but the file doesn't get uploaded.

@KTibow
Copy link

KTibow commented Mar 15, 2020

@jackshifter try running the code in the Python 3 IDLE without to_dict and after the code finishes run type on the result. Can you upload a small file using regular upload?

@KTibow
Copy link

KTibow commented Mar 16, 2020

@Kansattica I just throw away the result from upload_async(), and it already blocks without calling to_dict(). Although when I download it is async, as I said in #173.

@MihajaElrich
Copy link

MihajaElrich commented Jul 16, 2020

@jackshifter I have the same error as you, have you ever managed to fix it ?
Thanks

Python 3.6
onedrivesdk==1.1.8

@KTibow
Copy link

KTibow commented Jul 16, 2020

@MihajaElrich you don't need to call to_dict. The returned value isn't useful at all from upload_async, and it is getting uploaded. Here's an example using progress in some of my code I've wrote:
https://github.com/KTibow/pi-DriveUp/blob/19c6acb1f90a453d5b6984b1f302049f79dd293b/backup.py#L112
https://github.com/KTibow/pi-DriveUp/blob/19c6acb1f90a453d5b6984b1f302049f79dd293b/backup.py#L34-L35

@baywet
Copy link
Member

baywet commented Oct 2, 2024

Thank you for reaching out and for your patience. This SDK is being officially deprecated. See #209 for more information

@baywet baywet closed this as not planned Won't fix, can't repro, duplicate, stale Oct 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants