c# - 从 Thumbor 读取图像
问题描述
我在我的电脑上Thumbor
用作Docker
图像。我可以将图像保存到 Thumbor,但无法从 URL 读取图像
这是我用来保存文件的方法
var httpClient = new HttpClient();
var httpContent = new ByteArrayContent(FileToByteArray(filename));
HttpResponseMessage response = null;
try
{
httpContent.Headers.Add("Content-Type", "image/jpg");
response = httpClient.PostAsync("http://localhost:32773/image", httpContent).Result;
}
catch (HttpRequestException ex)
{
}
我正在使用邮递员的这个 URL,它会引发错误400Bad Request
http://localhost:32773/1.jpg
我在 URL 中遗漏了什么吗?任何人都可以帮助我提供示例 C# 代码吗?感谢你的帮助!
解决方案
正确的请求 URL 是:
http://localhost:32773/image/<the original location response>
这是存储图像的示例
POST http://192.168.2.48:8082/image
HTTP/1.1 201 Created
Date: Thu, 05 Mar 2020 11:56:12 GMT
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Location: /image/8ad1c65a3e6341cfb231b1faf438fc0e/image.jpg
Server: TornadoServer/4.5.3
获取相同的图像:
GET http://192.168.2.48:8082/image/8ad1c65a3e6341cfb231b1faf438fc0e/image.jpg
简而言之:确保在存储图像时存储响应标头中的位置信息
推荐阅读
- javascript - 如何从通过 WebRequest 对象加载的页面调用 javascript 函数
- laravel-envoy - 我在特使脚本中提供了密码,但它提示手动输入密码
- android - Pjsip Android 视频通话:倒转视频预览
- javascript - javascript如何解析参数?
- angular - 为什么在使用 [ngModel]="true" 时每个生命周期挂钩上的 this.value 未定义/为空
- javascript - Angular UI 路由器刷新正在处理父状态问题
- tensorflow - Keras:KMP_AFFINITY 是关键输出吗?
- delphi - Delphi 6中如何将TVirtualStringTree的所有节点保存到BMP?
- r - 与excel表相关的R官员图
- javascript - 如何使 jquery gridnav 库兼容并使用 jquery 3.3.1