EinfachHans / capacitor-email-composer

E-Mail Composer Plugin for Capacitor
MIT License
21 stars 7 forks source link

Send attachments from device storage #38

Closed sam-higgs closed 1 week ago

sam-higgs commented 1 week ago

It would be nice to be able to send attachments that are stored on device storage using https://capacitorjs.com/docs/apis/filesystem, this was previously possible with https://www.npmjs.com/package/cordova-plugin-email-composer?activeTab=readme

EinfachHans commented 1 week ago

You can send attachments that are stored on the device: https://github.com/EinfachHans/capacitor-email-composer?tab=readme-ov-file#device-storage

sam-higgs commented 1 week ago

This doesn't appear to work for me, at least on iOS with something like:

const { uri } = Filesystem.writeFile({
    path, // name of file
    directory: Directory.Cache, 
    data, // JSON string 
    encoding: Encoding.UTF8,
  });
...
await EmailComposer.open({ subject, attachments: [{ path: uri, type: "absolute", name: "foo.json" }] })

uri being something like "file:///var..." and the error is "File does not exist at absolute path"

EinfachHans commented 1 week ago

@sam-higgs Can you try to remove the file:// at the beginning of the uri?

sam-higgs commented 1 week ago

@EinfachHans Thanks, that seems to work!