Created
April 18, 2023 15:45
-
-
Save trozzelle/38ac90c5721c1fa1b6de488f8ca0eb11 to your computer and use it in GitHub Desktop.
Image upload code for making a Bluesky post.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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