Pull Media File
Overview
Pull media files from the dock with this interface. Instantly receive notifications of photo and video updates from wayline missions, or obtain the list of media files from the most recent wayline shoot. This allows edge device to process images at the dock end.

Pull Media Files
Access media files from the dock after mission complete and set the overall strategy for files uploading to the cloud.
// Subscribe to media file update notifications
static ErrorCode MediaFilesUpdateCallback(const MediaFile& file) {
// TODO: Process media file update notifications
return kOk;
}
auto media_manager = MediaManager::Instance();
// Register dock media file update notifications
media_manager->RegisterMediaFilesObserver(
std::bind(MediaFilesUpdateCallback, std::placeholders::_1));
// Media file reading initialization
auto media_file_reader = media_manager->CreateMediaFilesReader();
auto rc = media_file_reader->Init();
if (rc != kOk) {
ERROR("Failed to initialize media file reader");
return rc;
}
// Open media file, obtain media file file_path information through the previously registered notification interface
auto fd = media_file_reader->Open(media_file.file_path);
if (fd < 0) {
ERROR("Failed to open file");
return kErrorSystemError;
}
// Read file content
do {
auto nread = media_file_reader->Read(fd, buf, sizeof(buf));
if (nread > 0) {
// TODO: Read media files are in buf. Each read size is the same size of buf. When reading to the file size that less than buf, it returns the actual read size.
// For reading a media file, keep reading until the return data equals to the actual file size (this can be determined by the MediaFile's filesize parameter or is 0).
}
} while (nread > 0);
// End reading file
media_file_reader->Close(fd);
Dock Media File Strategy
Cloud Upload Strategy
By default, the dock automatically uploads media files captured by the aircraft to the cloud. Use the following interface to change this setting.
ErrorCode MediaManager::SetDroneNestUploadCloud(bool enable);
Note: If edge computing is offline for more than 30 seconds, the media file upload strategy will revert to the default. At this time, if historical media files exist, they will also be uploaded to the cloud.
Automatic Deletion Strategy
By default, the dock clears the local cache after uploading media files to the cloud. Use the following interface to change this setting. When edge computing needs to pull media files, this interface should be used to prevent the local media file cache from being cleared.
ErrorCode SetDroneNestAutoDelete(bool enable);
Notes:
- If edge computing is offline for more than 30 seconds, the deletion strategy will revert to the default. History media files that have been uploaded to cloud will not be cleared.
- When using the media file retrieval feature, disable the automatic media file deletion strategy at the Dock. Failure to regularly clear the Dock's storage space can lead to full storage, affecting wayline photography. Users can manually format the storage or use the cloud-based API to format based on storage usage.
Pull Raw Media Files
Initialize Media File Reading
Interface Prototype: ErrorCode MediaFilesReader::Init()
This interface allows you to establish a media file transfer connection with the dock. You can only access media files after successful initialization.
Note: This interface sets the dock's local media file strategy to not delete.
virtual ErrorCode Init() = 0;
Deinitialize Media File Reading
Interface Prototype: ErrorCode MediaFilesReader:DeInit()
This interface allows you to disconnect the media file transfer connection with the dock. When you no longer need to pull media files, call this interface to disconnect. After disconnection, you need to reinitialize to pull media files.
virtual ErrorCode DeInit() = 0;
Read Raw Media Files
Interface Prototype: int32_t MediaFilesReader::FileList(MediaFileList &filelist)
This interface gets the media file list from the most recent wayline mission.
Note: Only executed wayline missions that take photos and videos to produce media files, and have the delete strategy set to not delete, can retrieve the dock media file list through this interface.
Interface Prototype: FdType MediaFilesReader::Open(const std::string &file_path)
This interface opens a media file.
Note: The parameter is the media file path, which can be obtained from the media file update notification or from the FileList's retrieved media file list.
Interface Prototype: size_t MediaFilesReader::Read(FdType fd, void *buf, size_t count)
This interface reads the file stored in buf and returns the size of the valid data.
Note: The count parameter indicates the length of buf. The interface reads the data of count size to the end of the file.
Interface Prototype: size_t MediaFilesReader::Close(FdType fd)
Close the file using this interface after reading the data.
Return Value Description
Return Value | Description |
kOk | Operation successful |
Actual media file count or actual data read size | Operation successful |
Less than 0 | Operation failed |
kErrorSystemError | System error |
kErrorSendPackFailure | Failed to send the signal. Check the dock connection status |
kErrorRemoteFailure | Remote dock setting failed. Check the log for more information or contact technical support |