Skip to content

oss PutObject 需要使用 commonHeaders 中的 Content-Type 作为参数,但是 gateway-oss 会强行设为 application/octet-stream #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ganlvtech opened this issue Apr 2, 2024 · 1 comment

Comments

@ganlvtech
Copy link

https://help.aliyun.com/zh/oss/developer-reference/putobject

node_modules/@alicloud/gateway-oss/src/client.ts:130

    if (!Util.isUnset(request.body)) {
      if (String.equals(request.reqBodyType, "xml")) {
        let reqBodyMap = Util.assertAsMap(request.body);
        request.stream = new $tea.BytesReadable(XML.toXML(reqBodyMap));
        request.headers["content-type"] = "application/xml";
      } else if (String.equals(request.reqBodyType, "json")) {
        let reqBodyStr = Util.toJSONString(request.body);
        request.stream = new $tea.BytesReadable(reqBodyStr);
        request.headers["content-type"] = "application/json; charset=utf-8";
      } else if (String.equals(request.reqBodyType, "formData")) {
        let reqBodyForm = Util.assertAsMap(request.body);
        request.stream = new $tea.BytesReadable(OpenApiUtil.toForm(reqBodyForm));
        request.headers["content-type"] = "application/x-www-form-urlencoded";
      } else if (String.equals(request.reqBodyType, "binary")) {
        attributeMap.key = {
          crc: "",
          md5: "",
        };
        request.stream = OSSUtil.inject(request.stream, attributeMap.key);
        request.headers["content-type"] = "application/octet-stream";
      }

    }
@TsinghuaDream
Copy link

请看下这个SDK呢https://help.aliyun.com/zh/oss/developer-reference/node-js-1/?spm=a2c4g.11174283.0.0.58ecde53PbLOf0

当前仓库下的OSS SDK正在内部优化。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants