Upload files to devices in App Automate
App Automate provides preloaded media files on BrowserStack remote devices to test scenarios that require access to files on the device.
Apart from preloaded media files, you can also upload your media or non-media files in App Automate.
In this guide, you’ll learn:
- Supported file types and OS versions
- How to upload your files to BrowserStack
- How to set the uploadMedia parameter when executing your build
Supported file types and OS version
The following tab lists the supported files types you can upload, and OS version on which you can upload the files.
The following table shows the supported file types and their size to upload for testing:
File | Type | Maximum file size |
---|---|---|
Image | JPG, JPEG, PNG, GIF, BMP | 10 MB |
Video | MP4, MOV and 3GP | 50 MB |
Non-media | XLS, XLSX, DOC, DOCX, PDF, CSV, TXT | 15 MB |
The following table shows the supported OS and devices to which you can upload your files for testing:
OS | Device | OS version |
---|---|---|
iOS | iPhones and iPads | v13 and above (Non-media), v10 and above (Image, Video) |
Upload your file to BrowserStack
Run the following upload media cURL command to upload your file to BrowserStack servers:
curl -u "username:accesskey" \
-X POST "https://api-cloud.browserstack.com/app-automate/upload-media" \
-F "file=@/path/to/your/file" \
-F "custom_id=SampleFile"
A sample response for the given cURL command is as follows. It returns the value of the media_url
parameter.
{
"media_url": "media://90c7a8h8dc82308108734e9a46c24d8f01de12881",
"custom_id": "SampleFile"
}
The file you uploaded will be available in the following folders on the device:
Camera Roll.
The file path to camera roll directory is /private/var/mobile/Media/DCIM/
.
App’s directory in the device. The file path is Files app → On My iPhone → App's directory → ‘Custom_Files’ folder created by BrowserStack
.
Set uploadMedia parameter when executing build
In the execute build cURL command, set the uploadMedia
parameter to the value of the media_url
parameter returned in the API response.
The following sample cURL command shows the parameter used to access your uploaded files for testing on iPhone 8 Plus with iOS 11.0:
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/xcuitest/v2/build" \
-d '{"uploadMedia": ["media://90c7a8h8dc82308108734e9a46c24d8f01de12881"],
"devices": ["iPhone 8 Plus-11.0"], "app": "bs://f5L3azt9pLzE995f49376eb1fa3c284dc321f8d",
"testSuite": "bs://6eb1fa3c284ddbe9971b2d1aee0d52943b9c081"}' \
-H "Content-Type: application/json"
- The number of file uploads allowed per session is 5.
- In the case of non-media files, ensure that your iOS app has the
UIFileSharingEnabled
andLSSupportsOpeningDocumentsInPlace
keys set totrue
in theInfo.plist
file. This is required to make your app’s folder available in the Files app.
Need some help?
If you need any help with this feature, get in touch with us.
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!