De ce imi returneaza la comanda "APPEND"
Cod: Selectaţi tot
"{"request":"/1.1/media/upload.json","error":"Not found."}"
https://dev.twitter.com/rest/reference/post/media/upload-chunked
Cod: Selectaţi tot
var CHUNK_SIZE = 1024,
buffer = new Buffer(CHUNK_SIZE),
filePath = './web.mp4',
data, segment_index,
media = null;
async.series([
function (callback) {
request.post({
url: "https://upload.twitter.com/1.1/media/upload.json", oauth: oauth, host: "upload.twitter.com", protocol: "https:", formData: {
command: "INIT",
media_type: 'video/mp4',
total_bytes: 854429
}
}, function requestCallback(err, res, body) {
media = body;
segment_index = 0;
callback();
});
},
function (callback) {
var fd = fs.openSync(filePath, 'r');
var nread = fs.readSync(fd, buffer, 0, CHUNK_SIZE, null);
if (nread === 0) {
} else {
if (nread < CHUNK_SIZE) {
data = buffer.slice(0, nread);
} else {
data = buffer;
}
request.post({
url: "https://upload.twitter.com/1.1/media/upload.json", oauth: oauth, host: "upload.twitter.com", protocol: "https:", formData: {
command: "APPEND",
media_id: JSON.parse(media).media_id,
segment_index: segment_index,
media: data.toString('base64')
},
headers: {
'Content-Transfer-Encoding': 'base64'
}
}, function requestCallback(err, res, body) {
if (err) {
throw err;
}
});
}
callback();
}
], function (err) {
if (err) return null;
});
* Acest cod este pentru teste, am citit primi 1024 bytes doar pentru a testa raspunsul primit de la "APPEND" .