我正在创建脚本,用于通过Publishing APInodejs
将我的 APK 上传到 Google Play Developer ,但是它失败了。我认为,APK文件没什么问题,因为它是一个好文件。那么有什么想法可以解决这个问题吗?
我也尝试分段上传,但返回错误(我将很快附上)
以下是错误消息:
Upload successful! Server responded with: {
"error": {
"errors": [
{
"domain": "androidpublisher",
"reason": "apkInvalidFile",
"message": "Invalid APK file."
}
],
"code": 403,
"message": "Invalid APK file."
}
}
我的源代码
var https = require('https');
var request = require('request');
https.post = require('https-post');
var fs = require('fs');
var tokens = process.argv[2];
var formData = {
my_file: fs.createReadStream('example_file.apk')
}
if (tokens != '')
{
var url_create_listing = 'https://www.googleapis.com/androidpublisher/v2/applications/com.example.apps/edits?access_token='+tokens;
request.post( url_create_listing, function (error, response, body) {
var str_body = JSON.parse (body);
var listing_id = str_body.id;
var url_upload = 'https://www.googleapis.com/upload/androidpublisher/v2/applications/com.example.apps/edits/'+listing_id+'/apks?uploadType=media&access_token='+tokens;
var options = {
url: url_upload,
headers: {
'Content-Type': 'application/vnd.android.package-archive'
}
};
request.post( options, function optionalCallback(err, httpResponse, body)
{
if (err) {
return console.error('upload failed:', err);
}
console.log('Upload successful! Server responded with:', body);
}).pipe(fs.createReadStream('example_file.apk'));
});
}