【问题标题】:Buffer typescript to byte[] C#将打字稿缓冲到字节 [] C#
【发布时间】:2017-09-27 14:50:04
【问题描述】:

我正在尝试将 Buffer[] 从 typescript 发送到 C# 中的端点,以操纵接收到的文件,如下所示:

.TS:

let goiaba = new Buffer("I'm a string!", "utf-8")
params.path = "File/UploadSync2";
let path = params.getRequestParams();
let uri = `${this.baseUrl}/${path}`;
let options = {
  method: 'POST',
  url: uri,
  headers: params.header,
  form: {goiaba}
};
options.headers['Content-Type'] = 'application/x-www-form-urlencoded';
return requestAsync.postAsync(options);

C# 端点:

public Result<PutObjectResponse> UploadSync2(byte[] goiaba)
{
   return null;
}

问题是 goiaba 正在接收 {byte[0]}。 我该怎么做?

【问题讨论】:

  • 只是个小插曲,但你试过把参数改成string goiaba吗?
  • 是的,但没有成功
  • 这与 TypeScript 无关。
  • 我知道...你有什么想法吗?

标签: c# file typescript byte buffer


【解决方案1】:

如果您的 postAsync 实际使用 Ajax,则可能通过将 form: {goiaba} 更改为 data: goiaba 来完成这项工作

【讨论】:

    猜你喜欢
    • 2012-07-17
    • 1970-01-01
    • 2010-09-27
    • 2017-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多