java.lang.Object | |
↳ | com.google.android.gms.nearby.connection.Payload.File |
Represents a file in local storage on the device.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the
File that backs this File. | |||||||||||
Gets the
ParcelFileDescriptor from which to read the data of this File; useful when
reading the File in a streaming fashion, before the entire contents have arrived from the
remote endpoint. | |||||||||||
Gets the size of this Payload.File in bytes.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Gets the File
that backs this File. When receiving a File, this File
will be written to the device's Downloads folder (as returned by getExternalStoragePublicDirectory(String)
), and can then be copied or moved
(read on for how to do this safely) to your app's private storage, if necessary.
Note that when receiving a Payload.File
, the call to onPayloadReceived(String, Payload)
occurs at the start of the data transfer; i.e., at the
time of the call, this File
exists but may not yet contain all of its data.
Wait for updates to onPayloadTransferUpdate(String, PayloadTransferUpdate)
to indicate the transfer
has completed before attempting to move the File
. If you want to read the
data as it comes in, use asParcelFileDescriptor()
to get a streaming interface to the
incoming Payload.File
data.
Note: The file is saved in the local device's Downloads folder under a generic name with
no extension. The client app is responsible for renaming this File
and adding
an appropriate extension, if necessary, and all this (and possibly additional) metadata
should be transmitted by the remote device out-of-band (likely using a Payload of type BYTES
).
Returns | |
---|---|
File |
Gets the ParcelFileDescriptor
from which to read the data of this File; useful when
reading the File in a streaming fashion, before the entire contents have arrived from the
remote endpoint.
Returns | |
---|---|
ParcelFileDescriptor |
Gets the size of this Payload.File in bytes. For an incoming File, this is the expected size
of the File
once all data has been received. For an outgoing File, this is
simply the size of the File
or the available data in the ParcelFileDescriptor
at the time of construction.
Returns | |
---|---|
long |