Cloudinary API 图片上传的正确 React Native "file"?

Proper React Native "file" for Cloudinary API image upload?

http://cloudinary.com/documentation/image_upload_api_reference#upload

我尝试了以下方法:

用户从相机胶卷中选择:

{
    data: "/9j/4AAQSkZJRgABAQAASABIAAD/4QBYRXhpZg..."
    origURL: "assets-library://asset/asset.JPG?id=ED7AC36B-A150-4C38-BB8C-B6D696F4F2ED&ext=JPG",
    uri: "file:///Users/me/Library/Developer/CoreSimulator/Devices/1BC4A449-46CF-4ADE-A9B5-78906C9C50FB..."
}

然后在服务器上 (Node.js),我正在尝试使用上面的 uri

  addUserPhoto(uri) {
    const photo = new Promise((resolve, reject) => {
      const base64URI = new Buffer(uri).toString('base64');
      cloudinary.v2.uploader.upload('data:image/jpeg;base64,'+base64URI, {}, (result) => {
        console.log(result);
        resolve(result);
      });
    });
    return photo;
  }

但是我得到了错误: { message: 'Invalid image file', http_code: 400 }

我不确定 "file" 是否正确。我究竟做错了什么?我应该从相机胶卷数据中选择哪个字段,以及如何将其转换为 Cloudinary API 的兼容 "file"?

uri 是图像的本地文件路径(在 phone 上),因此服务器无法访问它。

将图像发送到远程主机的方法是发送数据。

所以它最终成为 data 之一。像这样:

data:image/jpeg;base64,/9j/4AAQSkZ...

之后,Node Express 给了我 Error: request entity too large(所以我认为它仍然是错误的)

原来我必须这样做: app.use(bodyParser.json({ limit: '50mb' })); app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));