Skip to content

Commit

Permalink
UploadSession type fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrem committed Apr 16, 2023
1 parent ef97c4f commit 1c73ea9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
5 changes: 2 additions & 3 deletions examples/onedrive/upload_large_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@

client = GraphClient(acquire_token_by_username_password)

chunk_size = 1 * 1024 * 1024
chunk_size = 3 * 1024 * 1024


def print_progress(range_pos):
print("{0} bytes uploaded".format(range_pos))



local_path = "../../tests/data/big_buck_bunny.mp4"
remote_folder = client.me.drive.root.get_by_path("archive")
remote_file = remote_folder.resumable_upload(local_path, chunk_size=chunk_size,
chunk_uploaded=print_progress).get().execute_query()
chunk_uploaded=print_progress).get().execute_query()
print(f"File {remote_file.web_url} has been uploaded")
17 changes: 14 additions & 3 deletions office365/runtime/odata/v4/upload_session.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
from office365.runtime.client_value import ClientValue
from office365.runtime.types.collections import StringCollection


class UploadSession(ClientValue):
"""The UploadSession resource provides information about how to upload large files to OneDrive, OneDrive for
Business, or SharePoint document libraries. """

def __init__(self, upload_url=None):
def __init__(self, upload_url=None, expiration_datetime=None, next_expected_ranges=None):
"""
:param str upload_url: The URL endpoint that accepts PUT requests for byte ranges of the file.
:param datetime expiration_datetime: The date and time in UTC that the upload session will expire.
The complete file must be uploaded before this expiration time is reached.
:param list[str] next_expected_ranges: A collection of byte ranges that the server is missing for the file.
These ranges are zero indexed and of the format "start-end" (e.g. "0-26" to indicate the first 27 bytes
of the file). When uploading files as Outlook attachments, instead of a collection of ranges,
this property always indicates a single value "{start}", the location in the file where the next upload
should begin.
"""
super(UploadSession, self).__init__()
self.expirationDateTime = None
self.nextExpectedRanges = None
self.uploadUrl = upload_url
self.expirationDateTime = expiration_datetime
self.nextExpectedRanges = StringCollection(next_expected_ranges)

0 comments on commit 1c73ea9

Please sign in to comment.