---
title: Upload your files with Appium | TestingBot
description: Upload files on TestingBot's remote mobile devices. Upload one or more
  photos to the iOS or Android photo gallery.
source_url:
  html: https://testingbot.com/support/app-automate/appium/upload-files
  md: https://testingbot.com/support/app-automate/appium/upload-files.md
---

# Upload files to physical devices

TestingBot provides a feature that allows you to specify one or more media files that need to be uploaded to a physical iOS or Android device, prior to running your Appium test. This functionality allows you to run tests that require media files (photos and videos) from the iOS or Android photo gallery.

There are two options to use this feature, depending on your usecase. We suggest using the first option, which will use TestingBot's custom `uploadMedia` capability.

- [TestingBot Upload Capability](https://testingbot.com#testingbot)
- [Appium Push and Pull](https://testingbot.com#appium)

## TestingBot Upload Capability

To use this functionality, you can use the `uploadMedia` capability, specifying an array of URLs to image files or video files. You can specify URLs to publicly downloadable media files, or you can use TestingBot Storage to upload the files to TestingBot and use the `tb://` URLs.

### Upload files to TestingBot
[cURL](https://testingbot.com#)

```bash
curl -u api_key:api_secret \
-X POST "https://api.testingbot.com/v1/storage" \
-F "file=@/path/to/app/file/media.png"
```

The API response will include a `tb://` URL, which you can use in the `uploadMedia` capability.

```json
{
  "app_url": "tb://edb4f4f3ed95a4f46714f3df"
}
```

Uploads to our TestingBot Storage are automatically deleted after 62 days.

### Add the capability to your Appium script
[Java](https://testingbot.com#) [NodeJS](https://testingbot.com#) [Python](https://testingbot.com#) [Ruby](https://testingbot.com#) [C#](https://testingbot.com#)

```java
Map<String, Object> tbOptions = new HashMap<>();
tbOptions.put("uploadMedia", new String[]{"tb://edb4f4f3ed95a4f46714f3df"});
options.setCapability("tb:options", tbOptions);
```

```javascript
const capabilities = {
  'tb:options': {
    'uploadMedia': ['tb://edb4f4f3ed95a4f46714f3df']
  }
}
```

```python
capabilities = {
  "tb:options" : {
    "uploadMedia" : ["tb://edb4f4f3ed95a4f46714f3df"]
  }
}
```

```ruby
capabilities = {
  "tb:options" => {
    "uploadMedia" => ["tb://edb4f4f3ed95a4f46714f3df"]
  }
}
```

```csharp
AppiumOptions options = new AppiumOptions();
var tbOptions = new Dictionary<string, object>();
tbOptions.Add("uploadMedia", new string[] { "tb://edb4f4f3ed95a4f46714f3df" });
options.AddAdditionalAppiumOption("tb:options", tbOptions);
```

TestingBot will add these files to the Android or iOS device. The metadata of the gallery on the device will be updated automatically, which means the media file will immediately appear in the device's gallery.

- **Android:** the media files will be added to the Default Gallery app. `/sdcard/Pictures` for images and `/sdcard/Movies` for videos.
- **iOS:** the media files will be added to the iOS Camera Roll: `com.apple.mobileslideshow`

## Appium Push and Pull

Appium provides both [pushFile](https://appium.io/docs/en/2.0/reference/interfaces/appium_types.ExternalDriver/#pushfile) and [pullFile](https://appium.io/docs/en/2.0/reference/interfaces/appium_types.ExternalDriver/#pullfile) functionality. This is supported since [Appium Version](https://testingbot.com/support/app-automate/appium/options#appiumVersion) 1.15.0.

With this approach, the file is pushed when the test has already started. Pushing media files to the iOS or Android device does not guarantee the updating of the metadata in the iOS or Android gallery, which means your media file might not appear (immediately).

### Android Example

Push a file to the SD Card of the Android device:

[Java](https://testingbot.com#) [NodeJS](https://testingbot.com#) [Python](https://testingbot.com#) [Ruby](https://testingbot.com#) [C#](https://testingbot.com#)

```java
// Push a file to the sdcard
driver.pushFile("/sdcard/Download/sample.png", new File(System.getProperty("user.home") + "/sample.png"));

// Pull file from sdcard
byte[] fileBase64 = driver.pullFile("/sdcard/Download/sample.png");
```

```javascript
// Push file - WebdriverIO syntax
const data = Buffer.from("TestingBot").toString('base64');
await driver.pushFile('/sdcard/Download/sample.txt', data);

// Pull file WebdriverIO example
const fileData = await driver.pullFile('/sdcard/Download/sample.txt');
```

```python
# Push a file
dest_path = '/sdcard/Download/sample.txt'
driver.push_file(dest_path, 'TestingBot'.encode("utf-8"))

# Pull file
file_base64 = driver.pull_file(dest_path)
```

```ruby
# Push a file
driver.push_file('/sdcard/Download/sample.png', File.read('/Users/testingbot/Desktop/sample.png'))

# Pull file
driver.pull_file('/sdcard/Download/sample.png')
```

```csharp
// Push a file
driver.PushFile("/sdcard/Download/sample.png", new FileInfo("/Users/testingbot/Desktop/sample.png"));

// Pull file
byte[] fileBase64 = driver.PullFile("/sdcard/Download/sample.png");
```

### iOS Example

Before using the pull and push functionality, you'll need to ensure that:

- Your iOS app must have set the `UIFileSharingEnabled` key to `true` in the `Info.plist` file, which enables file sharing.

- Alternatively, you can set the `LSSupportsOpeningDocumentsInPlace` key to `true` in the `Info.plist` to expose your app's folder in the **Files** app on the iOS device.

The destination path to push a file is in the following format: `@<app_bundle_id>:documents/<image_name>.<extension>`

[Java](https://testingbot.com#) [NodeJS](https://testingbot.com#) [Python](https://testingbot.com#) [Ruby](https://testingbot.com#) [C#](https://testingbot.com#)

```java
// Push an image file
driver.pushFile("@com.testingbot.Sample-App:documents/sample.png", new File("/Users/testingbot/Desktop/sample.png"));

// Pull file
byte[] fileBase64 = driver.pullFile("@com.testingbot.Sample-App:documents/sample.png");
```

```javascript
// Push file WebdriverIO example
const data = Buffer.from("TestingBot").toString('base64');
await driver.pushFile('@com.testingbot.Sample-App:documents/sample.txt', data);

// Pull file WebdriverIO example
const fileData = await driver.pullFile('@com.testingbot.Sample-App:documents/sample.txt');
```

```python
# Push an image file
driver.push_file('@com.testingbot.Sample-App:documents/sample.png', source_path='/Users/testingbot/Desktop/sample.png')

# Push a text file
dest_path = '@com.testingbot.Sample-App:documents/sample.txt'
driver.push_file(dest_path, 'TestingBot'.encode("utf-8"))

# Pull file
file_base64 = driver.pull_file(dest_path)
```

```ruby
# Push an image file
driver.push_file('@com.testingbot.Sample-App:documents/sample.png', File.read('/Users/testingbot/Desktop/sample.png'))

# Pull file
driver.pull_file('@com.testingbot.Sample-App:documents/image.png')
```

```csharp
// Push an image file
driver.PushFile("@com.testingbot.Sample-App:documents/image.png", new FileInfo("/Users/testingbot/Desktop/sample.png"));

// Pull file
byte[] fileBase64 = driver.PullFile("@com.testingbot.Sample-App:documents/sample.png");
```

### Looking for more help?

Have questions or need more information? Reach out via email or Slack.

[Email us](https://testingbot.com/contact/new) [Join our Slack](https://join.slack.com/t/testingb0t/shared_invite/zt-3bcw9xch-jk19~6XPs_xBrsAgAedkCw)
