Skip to main content
No Result Found

Media API

BrowserStack provides support for uploading media files for testing

You can use your own media and non-media files for testing. To know what files are supported, see the Supported file formats section in Test your files. Before starting the test execution, upload these test files, and fetch the details of the uploaded files on BrowserStack using REST API. You can read more on the use cases of test file upload functionality.

Upload media file

POST /automate/upload-media

Upload media files you want to use in your tests.

Note: You can upload up to 10 media files on the BrowserStack server. By default, we delete the uploaded files after 30 days from the date of upload.

Request Parameters

Request

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" -X POST "https://api-cloud.browserstack.com/automate/upload-media" -F "file=@/path/to/app/file/test.jpg"
  • file* File

    Media File to upload.

Response Attributes 200 application/json

Response

{
    "media_url": "media://90c7a8h8dc82308108734e9a46c24d8f01de12881"
}
  • media_url String

    Unique identifier returned upon successful upload of your media file on BrowserStack. This value is used to specify the media files to be used in your tests.

List uploaded media files

GET /automate/recent_media_files

Retrieve the list of recently uploaded media files to check the media_name, media_url, media_id, and uploaded_at attributes of the uploaded files.

Request Parameters

Request

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" -X GET https://api-cloud.browserstack.com/automate/recent_media_files
  • No parameter required.

Response Attributes 200 application/json

Response

[
    {
        "media_name": "profile.png",
        "media_url": "media://90c7a8h8dc82308108734e9a46c24d8f01de12881",
        "media_id": "90c7a8h8dc82308108734e9a46c24d8f01de12881",
        "uploaded_at": "2020-08-19 19:32:47 UTC"
    },
    {...}
]
  • Array

    List of recently uploaded media files.

  • media_name String

    Name of the uploaded media file.

  • media_url String

    Unique identifier returned upon successful upload of your media file on BrowserStack. This value is used to specify the media files to be used in your tests.

  • media_id String

    Unique ID returned on successful upload of your media file on BrowserStack.

  • uploaded_at String

    Media upload timestamp.

Delete media file

DELETE /automate/custom_media/delete/{media_id}

Mention the media_id of a file to delete the uploaded media files.

You can get the media_id of a file from the list of uploaded media files.

Request Parameters

Request

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" -X DELETE https://api-cloud.browserstack.com/automate/custom_media/delete/media_id
  • media_id* String

    ID of the media file to be deleted.

Response Attributes 200 application/json

Response

{
    "success": true
}
  • success Boolean

    Indicates whether deletion was success or a failure.

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

Download Copy Check Circle