Skip to content

Update UploadSession to implement new IUploadSession interface#45

Merged
MIchaelMainer merged 2 commits intomasterfrom
andrueastman/UploadTests
Dec 6, 2019
Merged

Update UploadSession to implement new IUploadSession interface#45
MIchaelMainer merged 2 commits intomasterfrom
andrueastman/UploadTests

Conversation

@andrueastman
Copy link
Contributor

@andrueastman andrueastman commented Dec 6, 2019

Changes proposed in this pull request

This PR updates UploadSession to implement IUploadSession to provide request builder compatibility with the LargeFileUploadTask work on this PR.

This should be merged in after the PR has been completed and deployed.

@andrueastman andrueastman self-assigned this Dec 6, 2019
@andrueastman
Copy link
Contributor Author

Build should succeed once the nuget package with the IUploadSession is out.

Set minimum package reference to 1.19.0-preview.5 to support this checkin.
@darrelmiller
Copy link

:shipit:

@MIchaelMainer
Copy link
Contributor

How to use the the v1.0 service library with the LargeFileUploadTask described in microsoftgraph/msgraph-sdk-dotnet-core#65

You can use your authenticated GraphServiceClient to get the uploadsession like this:

var uploadSession = await graphClient.Drive.Items["01KGPRHTV6Y2GOVW7725BZO354PWSELRRZ"]
                                                                       .ItemWithPath("_hamilton.png")
                                                                       .CreateUploadSession()
                                                                       .Request().PostAsync();
                    
LargeFileUploadTask<DriveItem> largeFileUploadTask = new LargeFileUploadTask<DriveItem>(uploadSession);

Subsequent steps will be the same.

@MIchaelMainer MIchaelMainer merged commit 0cf9fee into master Dec 6, 2019
@MIchaelMainer MIchaelMainer added this to the 0.10.0-preview milestone Dec 6, 2019
@andrueastman
Copy link
Contributor Author

andrueastman commented Dec 9, 2019

You can also obtain an upload session for a FileAttachement like this

var attachement = new AttachmentItem
{
    Name = "Attachment.pdf",
    Size = fileStream.Length
};

var uploadSession = await graphClient.Me.Messages[messageId].Attachments.CreateUploadSession(attachement).Request().PostAsync();

LargeFileUploadTask<FileAttachment> largeFileUploadTask = new LargeFileUploadTask<FileAttachment>(uploadSession, fileStream);

Subsequent steps will be the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants