PHP 'array() image' 等效于 javascript

问题描述

我正在尝试通过他们的 API v2 将图像上传到 Etsy 列表。他们的文档有用PHP上传图片代码示例,其中POST请求正文参数是这样给出的

$params = array('@image' => '@'.$source_file.';type='.$mimetype);

我将如何在 JavaScript 中复制它?我尝试将图像 blob 作为图像参数发送,但似乎不起作用。

编辑:我正在使用 npm oauth 包。这是我用来调用 API 的完整代码

var oauth1 = new OAuth1.OAuth(
        'https://openapi.etsy.com/v2/oauth/request_token?scope=email_r%20listings_r%20listings_w%20listings_d','https://openapi.etsy.com/v2/oauth/access_token','api_key','api_secret','1.0A',null,'HMAC-SHA1'
      );
    oauth1.post(
    'https://openapi.etsy.com/v2/listings/915677000/images',req.user.etsy.oauth_token,req.user.etsy.oauth_token_secret,{
        'listing_id': 915677000,'image': <image has to go here>
    },'multipart/form-data',function (e,data,response){
        if (e) console.error(e);
        // let body = JSON.parse(data);
        console.log(data);
        res.redirect('/create-listings')
    });

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)