Skip to content

Instantly share code, notes, and snippets.

@trozzelle
Created April 18, 2023 15:45
Show Gist options
  • Save trozzelle/38ac90c5721c1fa1b6de488f8ca0eb11 to your computer and use it in GitHub Desktop.
Save trozzelle/38ac90c5721c1fa1b6de488f8ca0eb11 to your computer and use it in GitHub Desktop.
Image upload code for making a Bluesky post.
// Provide a uint8array of image data and set MIME type.
// Bluesky only supports jpg and png at the moment.
const testUpload = await agent.uploadBlob(testPng, {encoding: "image/png"})
// The response contains a BlobRef object, which is what
// agent.post expects.
const result = await agent.post({
text: 'Post Text',
reply: {
parent: {
uri: notif.uri,
cid: notif.cid,
},
root: {
uri: notif.uri,
cid: notif.cid,
},
},
embed: {
images: [
{
image: testUpload.data.blob,
alt: "",
},
],
$type: "app.bsky.embed.images",
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment