我正在使用RestSharp(Visual Studio 2013中的版本105.2.3.0,.net 4.5)来调用NodeJS托管的Web服务.我需要做的一个调用是上传文件.使用RESTSharp请求,如果我从我的端部检索流到字节数组并将其传递给AddFile,它工作正常.但是,我更倾向于流内容而不是在服务器内存中加载整个文件(文件可以是100的MB).
如果我设置一个动作来复制我的流(见下文),我在System.Net.ProtocolViolationException的"MyStream.CopyTo"行中得到一个异常(要写入流的字节超过指定的Content-Length字节大小) .在调用client.Execute之后,在Action块中抛出此异常.
根据我的阅读,我不应该手动添加Content-Length标头,如果我这样做,它也无济于事.我已经尝试将CopyTo缓冲区设置为小值和大值,以及完全省略它,但无济于事.有人能给我一些我错过的暗示吗?
// Snippet...
protected T PostFile<T>(string Resource, string FieldName, string FileName,
string ContentType, Stream MyStream,
IEnumerable<Parameter> Parameters = null) where T : new()
{
RestRequest request = new RestRequest(Resource);
request.Method = Method.POST;
if (Parameters != null)
{
// Note: parameters are all UrlSegment values
request.Parameters.AddRange(Parameters);
}
// _url, _username and _password are defined configuration variables
RestClient client = new RestClient(_url);
if (!string.IsNullOrEmpty(_username))
{
client.Authenticator = new HttpBasicAuthenticator(_username, _password);
}
/*
// Does not work, …Run Code Online (Sandbox Code Playgroud) 我将 Docker 与 AWS ECR 存储库一起使用。他们指示您执行的步骤之一是运行“docker tag”以使用标签标记构建的映像,该标签包含映像将在 ECR 中存储的“完全限定”位置。
我正在将我必须的脚本迁移到 Python API(而不是对 docker 客户端进行 shell 调用)。我无法在https://docker-py.readthedocs.io/en/stable/images.html的 API 文档中找到等效的“docker tag” 。
有人可以指出我正确的方向吗?