You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have tried using the videos.insert function asynchronously as well as with a callback function. When using with a callback function the code still executes asynchronously (which was unexpected, as without a callback it executes asynchronously as well).
I cannot seem to log the response. Below is my use of the function without the callback. In this case, the upload reaches 100%, but no response is logged. The log code isn't even reached, nothing is logged after the upload reaches 100%. With the callback function, the callback is executed before the upload completes.
async function upload(
oauth2Client,
videoInfo,
thumbInfo,
publishAt,
title,
description,
notifySubscribers
) {
let result = {};
// this await is needed because the insert function can optionally return a promise
// which is what we want, ignore the underline in your IDE
try {
const res = await youtube.videos.insert(
{
auth: oauth2Client,
part: "id,snippet,status",
notifySubscribers,
requestBody: {
snippet: {
title,
description,
},
status: {
privacyStatus: "private",
publishAt,
},
},
media: {
body: fs.createReadStream(videoInfo.path),
mimeType: videoInfo.mime,
},
},
{
onUploadProgress: (evt) => {
const progress = Math.round((evt.bytesRead / info.length) * 100);
// readline.clearLine(process.stdout, 0);
// readline.cursorTo(process.stdout, 0, null);
// process.stdout.write(`${progress}% complete`);
logger.log(
"debug",
`Uploading file ${basename(filePath)} ${progress}%`
);
},
}
);
logger.log("sensitive", "== Upload Response ==", res.data);
result["data"] = res.data;
} catch (error) {
logger.log("error", "The API is not doing API things", error);
result["error"] = "Possibly rate limited";
}
return result;
}
type: questionRequest for information or clarification. Not an issue.priority: p3Desirable enhancement or fix. May not be included in next release.
1 participant
Converted from issue
This discussion was converted from issue #3556 on February 04, 2025 19:31.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have tried using the videos.insert function asynchronously as well as with a callback function. When using with a callback function the code still executes asynchronously (which was unexpected, as without a callback it executes asynchronously as well).
I cannot seem to log the response. Below is my use of the function without the callback. In this case, the upload reaches 100%, but no response is logged. The log code isn't even reached, nothing is logged after the upload reaches 100%. With the callback function, the callback is executed before the upload completes.
Beta Was this translation helpful? Give feedback.
All reactions