← 输入框|github.com|刷新
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

Open

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);
        }
    }

Activity

  1. mudnug commented on Jan 16, 2015

    @mudnug

    This is impacting me as well

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

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