Skip to content
New issue

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

sendFile method always mimeType: application/octet-stream #777

Open
Gromov812 opened this issue Feb 24, 2025 · 0 comments
Open

sendFile method always mimeType: application/octet-stream #777

Gromov812 opened this issue Feb 24, 2025 · 0 comments

Comments

@Gromov812
Copy link

Gromov812 commented Feb 24, 2025

Hi! I've tried to send photo via sendFile. Full construction is

 client.sendFile(username, {
          file: data?.bufferFile, // U
          forceDocument: false,
          fileName: `${data?.picName}`, // Picture 2024-08-26 10-25-14.png
          mimeType: `image/${data?.picExt}`, // image/png
          caption: data?.message || "", // ""
          attributes: [new Api.DocumentAttributeFilename({ 
            fileName: `${data?.picName}`, //Picture 2024-08-26 10-25-14.png

           })],
        })

The buffer image i get from front-end via socket.io:

      const reader = new FileReader();
     reader.readAsArrayBuffer(pic);
      reader.onload = async () => {
        const picName = pic.name;
        const picExt = pic.type.split('/');

        const buffer = await pic.arrayBuffer();
        buffer.name = pic.name;

        const bytes = new Uint8Array(buffer);

      }    

So its always sent as file, not a photo. Any ideas to fix it?

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant