Upload file custom command
Use the Upload file custom command to upload a file directly to a specified path on any
device. Starting with IBM®
MaaS360® Android version
9.15, administrators can remotely upload files to managed devices by using the
upload-file custom command. This command allows file transfers from a secure URL or
by embedding the file data directly within the custom command. It enhances device management by
enabling file deployment, updates, and cleanup operations without requiring user
intervention.
Supported options
The following options control how the file is uploaded to the device.
- -url <url>
- Uploads a file from the specified HTTPS URL. The URL must be publicly accessible and properly formatted.
- -base64 <base64>
- Uploads a file by using Base64-encoded data that is suitable for small files.
- -delete
- Deletes a previously uploaded file from the device.
- -notify
- (Optional) Notifies the user about the file upload or deletion.
- -verify <sha-256>
- (Optional) Verifies the SHA-256 hash of the downloaded file. The hash must be a 64-character hexadecimal string.
Destination file name and path
The destination path can be an absolute path (for example,
/path/to/file.ext)
or a relative path by using predefined constants. If a file exists at the specified path, it is
replaced.Note: Absolute paths are supported only on Android 10 or earlier.
The following table describes the supported path constants for the custom command action.
| Constant | Android Version | File type | Description |
|---|---|---|---|
%directory_external% |
Android 10 and earlier | Any | Root of external storage device |
%directory_alarms% |
All | Audio | Directory for alarm audio files |
%directory_audiobooks% |
Android 10 and later | Audio | Directory for audiobook files |
%directory_dcim% |
All | Image, Video | Location for pictures and videos |
%directory_documents% |
All | Any | Directory for user-created documents |
%directory_downloads% |
All | Any | Directory for downloaded files |
%directory_movies% |
All | Video | Directory for movies |
%directory_music% |
All | Audio | Directory for music files |
%directory_notifications% |
All | Audio | Directory for notification sounds |
%directory_pictures% |
All | Image, Video | Directory for user pictures |
%directory_podcasts% |
All | Audio | Directory for podcast files |
%directory_recordings% |
Android 12 and later | Audio | Directory for voice recordings |
%directory_ringtones% |
All | Audio | Directory for ringtones |
%directory_screenshots% |
Android 10 and later | Image | Directory for screenshots |
Notes:
- Access to legacy paths is limited to Android 10 and earlier or requires custom firmware permissions.
- Ensure that file types match the expected formats for each directory (for example, .jpg for images).
- Read and Write External Storage permissions are required on Android 10 or earlier.
- Work profile-enrolled devices can only access restricted folders.
Examples
- Upload a file from a URL to a subpath in the Downloads folder for the current
user.
upload-file -url https://example.com/file.ext %directory_downloads%/file.ext - Upload a file from a URL to a subpath in the Downloads folder for the current user after
verifying the SHA-256 hash, and notify the user.
upload-file -url https://example.com/file.ext -notify -verify 70ba33708cbfb103f1a8e34afef333ba7dc021022b2d9aaa583aabb8058d8d67 %directory_downloads%/file.ext - Upload Base64 encoded file data to a direct path on the device.
upload-file -base64 ZmlsZSBkYXRhIGdvZXMgaGVyZQphbm90aGVyIGxpbmUKeWV0IGFub3RoZXI= /some/path/file.ext - Delete a previously uploaded file.
upload-file -delete %directory_downloads%/file.ext