mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Twitter-video-upload-ver01
I tried to write the code but it doesn't work. I would like to be able to upload a video or a larger gif file with this module.
This commit is contained in:
parent
9bae313b72
commit
afbed8853b
@ -612,14 +612,11 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
var mediaPromise;
|
var mediaPromise;
|
||||||
if (msg.media && Buffer.isBuffer(msg.media)) {
|
if (msg.media && Buffer.isBuffer(msg.media)) {
|
||||||
// var mediaType = fileType(msg.media);
|
|
||||||
// if (mediaType === null) {
|
mediaPromise = node.twitterConfig.post("https://upload.twitter.com/1.1/media/upload.json",{
|
||||||
// node.status({fill:"red",shape:"ring",text:"twitter.status.failed"});
|
command: "INIT",
|
||||||
// node.error("msg.media is not a valid media object",msg);
|
total_bytes: msg.mediaSize,
|
||||||
// return;
|
media_type: msg.mediaType
|
||||||
// }
|
|
||||||
mediaPromise = node.twitterConfig.post("https://upload.twitter.com/1.1/media/upload.json",null,null,{
|
|
||||||
media: msg.media
|
|
||||||
}).then(function(result) {
|
}).then(function(result) {
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
return result.body.media_id_string;
|
return result.body.media_id_string;
|
||||||
@ -628,6 +625,31 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
mediaPromise = node.twitterConfig.post("https://upload.twitter.com/1.1/media/upload.json",{
|
||||||
|
command: "APPEND",
|
||||||
|
media_id: mediaId,
|
||||||
|
media: msg.media,
|
||||||
|
segment_index: 0
|
||||||
|
}).then(function(result) {
|
||||||
|
if (result.status === 200) {
|
||||||
|
return result.media_id;
|
||||||
|
} else {
|
||||||
|
throw new Error(result.body.errors[0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mediaPromise = node.twitterConfig.post("https://upload.twitter.com/1.1/media/upload.json",{
|
||||||
|
command: "FINALIZE",
|
||||||
|
media_id: mediaId
|
||||||
|
}).then(function(result) {
|
||||||
|
if (result.status === 200) {
|
||||||
|
return result.media_id;
|
||||||
|
} else {
|
||||||
|
throw new Error(result.body.errors[0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
mediaPromise = Promise.resolve();
|
mediaPromise = Promise.resolve();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user