Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Nov 29, 2021. It is now read-only.
This repository was archived by the owner on Nov 29, 2021. It is now read-only.

UploadFileTask with Stream fails to upload files #129

Copy link
Copy link
@saguiitay

Description

@saguiitay
Issue body actions

The WebRequest is invalid, since it sets a wrong value to the Content-Length header. In the sample below, it sets it to 339 bytes, instead of 329 bytes. Notice that the overloaded method that accepts a byte[] works correctly.

Here's a failing test:

    [TestMethod]
    public void Can_Upload_File_Task_FAILS()
    {
        var localFile = new FileInfo(_fixture.CreateAnonymous<string>());
        var localContent = _fixture.CreateAnonymous<string>();

        File.WriteAllText(localFile.FullName, localContent, System.Text.Encoding.UTF8);
        Assert.IsTrue(File.Exists(localFile.FullName));

        using (var stream = new FileStream(localFile.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
        {
            var uploadTask = _client.UploadFileTask("/Test", localFile.Name, stream);
            uploadTask.Wait();

            Assert.IsNotNull(uploadTask.Result);
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.