Open
Description
Hello,
I am trying to do chunk media upload for an Image. While my media/upload ( INIT) calls works fine, the next call for media/upload (APPEND) fails with authentication error:
{ errors: [ { code: 32, message: 'Could not authenticate you.' } ] }
I am using the same client object to make both the POST calls.
const appMediaConfig = {
subdomain: 'upload',
consumer_key: process.env.CONSUMER_KEY,
consumer_secret: process.env.CONSUMER_SECRET,
access_token_key: process.env.ACCESS_TOKEN,
access_token_secret: process.env.ACCESS_TOKEN_SECRET,
timeout_ms: 60 * 1000 // optional HTTP request timeout to apply to all requests.
};
Here's my code:
// THIS WORKS
function initMediaUpload(){
return new Promise(async (resolve, reject) => {
try{
const result = await twitterUpload.post("media/upload",{
command: "INIT",
media_type: "image/jpeg",
total_bytes: WELCOME_IMAGE_SIZE,
media_category: "dm_image"
}
)
resolve(result);
}
catch (error) {
// console.log("ERROR",error)
reject(error);
}
})
}
// THIS FAILS
function appendMediaUpload(mediaid){
return new Promise(async (resolve, reject) => {
try{
const result = await twitterUpload.post("media/upload",{
command: "APPEND",
media_id: mediaid,
media: WELCOME_IMAGE,
segment_index: 0
})
resolve(result);
}
catch (error) {
console.log("ERROR",error)
reject(error);
}})
}
I am just calling the INIT function , save the media_id_string , then call the APPEND function with captured media_id_string.
I have been banging my head on this for quite some time now. Maybe i am missing something or is there a bug ?? Any help will be great ..
Thank you :)