Skip to content
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

putObject 中的 Body对象类型,验证逻辑太严格? #41

Closed
75k opened this issue Jun 18, 2018 · 3 comments
Closed

putObject 中的 Body对象类型,验证逻辑太严格? #41

75k opened this issue Jun 18, 2018 · 3 comments

Comments

@75k
Copy link

75k commented Jun 18, 2018

一个 Atom下的插件,更新 sdk 到最新版以后,没法上传了。提示:params body format error, Only allow File|Blob|String'

Body 使用 fs.readFileSync(filepath)fs.createReadStream(filepath) 都不行。尝试用 ToString ,别的地方又出错。

测试了一下,在命令行中,可以正常上传,Atom里就废了。 最后定位到这里:

var getFileSize = function (api, params, callback) {
    var size;
    if (util.isBrowser) {
        if (typeof params.Body === 'string') {
            params.Body = new global.Blob([params.Body]);
        }
        if (params.Body instanceof global.File || params.Body instanceof global.Blob) {
            size = params.Body.size;
        } else {
            callback({error: 'params body format error, Only allow File|Blob|String.'});
            return;
        }
    }

请问这是 Bug 还是要用其他方式传递 Body? 其他方式的话,应该是什么呢?新手学习中,很多函数不知道, 找了快一天了,没找到能用的办法。

@RuiZhuo
Copy link

RuiZhuo commented Jun 29, 2018

感觉是个bug来的,我直接在调用外部把isBrower给强制设为false,Body部分使用buffer。

@tychenjiajun
Copy link

@carsonxu
Copy link
Collaborator

已修复@tychenjiajun

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

4 participants