相关疑难解决方法(0)

上传Base64图片Facebook Graph API

我正在尝试使用Node.js将base64图像上传到FaceBook页面.如果我从文件系统中读取文件(即使用fs.readFileSync('c:\ a.jpg'),我已设法让上传工作所有的多部分数据等

但是,如果我使用base64编码的图像并尝试上传它,它会给我以下错误: {"error":{"message":"(#1) An unknown error occurred","type":"OAuthException","code":1}}

我已经尝试将其转换为二进制new Buffer(b64string, 'base64');并上传,但没有运气.

我现在已经为此奋斗了3天,所以任何帮助都会非常感激.

编辑:如果有人也知道如何将base64转换为二进制并成功上传它,这对我也有用.

编辑:代码片段

var postDetails = separator + newlineConstant + 'Content-Disposition: form-data;name="access_token"' + newlineConstant + newlineConstant + accessToken + newlineConstant + separator;

postDetails = postDetails + newlineConstant + 'Content-Disposition: form-data; name="message"' + newlineConstant + newlineConstant + message + newlineConstant;

//Add the Image information
var fileDetailsString = '';
var index = 0;
var multipartBody = new Buffer(0);
images.forEach(function (currentImage) {
    fileDetailsString = fileDetailsString + separator + newlineConstant + …
Run Code Online (Sandbox Code Playgroud)

javascript base64 encoding node.js facebook-graph-api

21
推荐指数
2
解决办法
2万
查看次数