FileSender

Struct FileSender 

Source
pub struct FileSender<'a, R: Runtime>(/* private fields */);
Expand description

API of sharing files with other apps.

§Examples

fn example(app: &tauri::AppHandle) {
    use tauri_plugin_android_fs::AndroidFsExt as _;
 
    let api = app.android_fs();
    let file_sender = api.file_sender();
}

Implementations§

Source§

impl<'a, R: Runtime> FileSender<'a, R>

Source

pub fn share_files<'b>( &self, uris: impl IntoIterator<Item = &'b FileUri>, ) -> Result<()>

Show app chooser for sharing files with other apps.
This function returns immediately after requesting to open the app chooser, without waiting for the app’s response.

This sends the files as a single unit. The available apps depend on the MIME types associated with the files.
This does not result in an error even if no available apps are found. An empty app chooser is displayed.

§Args
  • uris :
    Target file URIs to share.
    This all needs to be readable.
    Files in PrivateStorage cannot be used.
§Support

All.

§References

https://developer.android.com/reference/android/content/Intent#ACTION_SEND_MULTIPLE https://developer.android.com/reference/android/content/Intent#ACTION_SEND

Source

pub fn share_file(&self, uri: &FileUri) -> Result<()>

Show app chooser for sharing file with other apps.
This function returns immediately after requesting to open the app chooser, without waiting for the app’s response.

The available apps depend on the MIME type associated with the file.
This does not result in an error even if no available apps are found. An empty app chooser is displayed.

§Args
  • uri :
    Target file URI to share.
    Must be readable.
    Files in PrivateStorage cannot be used.
§Support

All.

§References

https://developer.android.com/reference/android/content/Intent#ACTION_SEND

Source

pub fn open_file(&self, uri: &FileUri) -> Result<()>

Show app chooser for opening file with other apps.
This function returns immediately after requesting to open the app chooser, without waiting for the app’s response.

The available apps depend on the MIME type associated with the file.
This does not result in an error even if no available apps are found. An empty app chooser is displayed.

§Args
  • uri :
    Target file URI to view.
    Must be readable.
    Files in PrivateStorage cannot be used.
§Support

All.

§References

https://developer.android.com/reference/android/content/Intent#ACTION_VIEW

Source

pub fn edit_file(&self, uri: &FileUri) -> Result<()>

Show app chooser for editing file with other apps.
This function returns immediately after requesting to open the app chooser, without waiting for the app’s response.

The available apps depend on the MIME type associated with the file.
This does not result in an error even if no available apps are found. An empty app chooser is displayed.

§Note

I think that this may be the least commonly used request for sending file to app.
Even if you want to open an image or video editing app, FileSender::open_file allows you to choose from a wider range of apps in many cases.

§Args
  • uri :
    Target file URI to view.
    Must be read-writeable.
    Files in PrivateStorage cannot be used.
§Support

All.

§References

https://developer.android.com/reference/android/content/Intent#ACTION_EDIT

Source

pub fn can_share_files<'b>( &self, uris: impl IntoIterator<Item = &'b FileUri>, ) -> Result<bool>

👎Deprecated: Since Android 11, This does not function correctly due to android security.

Determines whether the specified files can be used with FileSender::share_files.
If no app is available to handle the files, this returns false.

§Args
  • uris :
    Target file URIs to share.
    This all needs to be readable.
§Support

All.

Source

pub fn can_share_file(&self, uri: &FileUri) -> Result<bool>

👎Deprecated: Since Android 11, This does not function correctly due to android security.

Determines whether the specified file can be used with FileSender::share_file.
If no app is available to handle the file, this returns false.

§Args
  • uri :
    Target file URI.
    Must be readable.
§Support

All.

Source

pub fn can_open_file(&self, uri: &FileUri) -> Result<bool>

👎Deprecated: Since Android 11, This does not function correctly due to android security.

Determines whether the specified file can be used with FileSender::open_file.
If no app is available to handle the file, this returns false.

§Args
  • uri :
    Target file URI.
    Must be readable.
§Support

All.

Source

pub fn can_edit_file(&self, uri: &FileUri) -> Result<bool>

👎Deprecated: Since Android 11, This does not function correctly due to android security.

Determines whether the specified file can be used with FileSender::edit_file.
If no app is available to handle the file, this returns false.

§Args
  • uri :
    Target file URI.
    Must be read-writeable.
§Support

All.

Auto Trait Implementations§

§

impl<'a, R> Freeze for FileSender<'a, R>

§

impl<'a, R> RefUnwindSafe for FileSender<'a, R>

§

impl<'a, R> Send for FileSender<'a, R>

§

impl<'a, R> Sync for FileSender<'a, R>

§

impl<'a, R> Unpin for FileSender<'a, R>

§

impl<'a, R> UnwindSafe for FileSender<'a, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,