Skip to content
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

Description

@saguiitay

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
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions