A file (such as an image or document) attached to a feature in a ServiceFeatureTable or a GeodatabaseFeatureTable. More...
Header: | #include <Attachment.h> |
Since: | Esri::ArcGISRuntime 100.0 |
Inherits: | Esri::ArcGISRuntime::Object |
Public Functions
virtual | ~Attachment() override |
qint64 | attachmentId() const |
QUrl | attachmentUrl() const |
QString | contentType() const |
QFuture<QByteArray> | fetchDataAsync() |
bool | isDataFetched() const |
QString | name() const |
qint64 | size() const |
Detailed Description
Attachments allow you to associate files containing additional information with specific, relevant features. For example, a building inspector could attach a PDF of a permit to a building feature. Attachments are not stored as attributes, rather the attachment data is linked with the feature inside its ServiceFeatureTable or a GeodatabaseFeatureTable.
If a feature table supports attachments (ArcGISFeatureTable::hasAttachments), each feature in the table may have zero or more attachments. Get a feature's collection of attachments by calling ArcGISFeature::attachments. You can examine an attachment's name, type, and file size, and download the file using fetchDataAsync. Once downloaded, you can work with the data in your app (display it to the user, for example).
If a feature allows editing of its attachments (ArcGISFeature::canEditAttachments value is true
), you can add to the feature's collection of attachments using AttachmentListModel::addAttachmentAsync(QIODevice& ioDevice, const QString& contentType, const QString& name, QObject* parent). The data must be in one of the supported attachment formats. You can also update or delete attachments from the ArcGISFeature, as required.
Your app's available memory and storage space may impact the size of attachments you can add to a feature, or retrieve from the feature's collection. Apps that need to work with large attachments should be tested using representative physical devices and sample attachments.
Member Function Documentation
[override virtual]
Attachment::~Attachment()
Destructor.
[since Esri::ArcGISRuntime 100.1]
qint64 Attachment::attachmentId () const
Returns the ID of the attachment.
This function was introduced in Esri::ArcGISRuntime 100.1.
QUrl Attachment::attachmentUrl () const
Returns the URL of the attachment if its data is already fetched.
QString Attachment::contentType () const
Returns the MIME type of the attachment file.
[since Esri::ArcGISRuntime 200.2]
QFuture<QByteArray > Attachment::fetchDataAsync ()
Returns the attachment's data.
This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.
See Working with QFuture for further details.
This function was introduced in Esri::ArcGISRuntime 200.2.
bool Attachment::isDataFetched () const
Returns true
if the attachment data has already been retrieved, false
otherwise.
This is true
if the attachment data has been retrieved previously. Even so, you must call fetchData() to get the data. The operation should complete more quickly since the data is already available locally.
You can request attachment data proactively to reduce the time it takes to retrieve the data from its source. However, to avoid unnecessary communication overhead, you should fetch the data only when the user needs it.
QString Attachment::name() const
Returns the name of the attachment.
qint64 Attachment::size() const
Returns the size of the attachment's data in bytes.