We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://docs.xmtp.org/inboxes/content-types/attachments Can make this work given an existing URL
async sendRemoteAttachment(url: string) { try { // Fetch the image data const response = await fetch(url); if (!response.ok) { throw new Error(`Failed to fetch the image: ${response.statusText}`); } const arrayBuffer = await response.arrayBuffer(); // Create the attachment object const attachment = { filename: url.split("/").pop() || "image.jpg", mimeType: response.headers.get("content-type") || "image/jpeg", data: new Uint8Array(arrayBuffer), }; // Encode and encrypt the attachment const encryptedEncoded = await RemoteAttachmentCodec.encodeEncrypted( attachment, new AttachmentCodec(), ); // Create the remote attachment object const remoteAttachment: RemoteAttachment = { url: url, // Original URL contentDigest: encryptedEncoded.digest, salt: encryptedEncoded.salt, nonce: encryptedEncoded.nonce, secret: encryptedEncoded.secret, scheme: "https://", contentLength: attachment.data.byteLength, filename: attachment.filename, }; // Send the remote attachment await this.send(remoteAttachment, ContentTypeRemoteAttachment); return remoteAttachment; } catch (error) { console.error("Failed to send remote attachment:", error); throw error; } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
https://docs.xmtp.org/inboxes/content-types/attachments
Can make this work given an existing URL
The text was updated successfully, but these errors were encountered: