-
Notifications
You must be signed in to change notification settings - Fork 97
Open
Description
Twitter upload error details: {"error":"Error: Bad Request","stack":"Error: Error: Bad Request
at <anonymous> ([REDACTED]/virtuals-agent/node_modules/@virtuals-protocol/game-twitter-plugin/dist/index.js:400:19)
at fulfilled ([REDACTED]/virtuals-agent/node_modules/@virtuals-protocol/game-twitter-plugin/dist/index.js:50:24)
at processTicksAndRejections (:12:39)","blobSize":845517,"blobType":"image/png"}
If I do something wrong, it would be nice to have a working example for the media upload with the twitter plugin itself, as it is otherwise undocumented.
// Get the specific plot using fetch
const response = await fetch(url, {
headers: {
'Accept': 'image/png'
}
});
const data = await response.arrayBuffer();
// Convert the response to a blob with proper type
const plotBlob = new Blob([data], {
type: 'image/png',
endings: 'native'
});
const plotSize = plotBlob.size;
// Check size limit
if (plotSize > 5 * 1024 * 1024) {
throw new Error("Plot size exceeds 5MB limit");
}
// Upload to Twitter
try {
// Create FormData with proper multipart boundaries
const formData = new FormData();
// Add the file with proper content type
formData.append('file', plotBlob, `${plot_name}.png`);
// Upload using the Twitter client
const mediaId = await gameTwitterClient.uploadMedia(plotBlob);
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels