Programmable Media

React Native image and video upload

Last updated: Jan-29-2024

Cloudinary provides support for uploading media directly from your mobile application to your Cloudinary product environment, without going through your servers first. This method allows for faster uploading and a better user experience. It also reduces load on your servers and reduces the complexity of your applications.

This page covers common usage patterns for React Native image and video upload with Cloudinary.

For details on all available upload functionality, see the Upload guide, and the upload method of the Upload API Reference.

For security reasons, mobile applications shouldn't contain your Cloudinary product environment credentials. You can use a signed upload, but that requires generating an authentication signature on your backend. In most cases, you will probably use unsigned uploads that generally provide all the functionality you need for your mobile application, while restricting upload options that require more security.

Important
The React Native library is currently in Beta. There may be minor changes to naming or other implementation details before the general access release. We invite you to try it out. We would appreciate any feedback via our support team.

Upload method

The upload request is managed by the upload method, which accepts the file to upload, upload options and a callback.

For example, to upload an image called imageFile.jpg using the default settings:

The result of the upload API call is an object that provides information about the uploaded image, including the assigned public ID of the image and its URL.

Unsigned upload

Unsigned upload is an option for performing upload without the need to generate a signature on your backend. Unsigned upload options are controlled by an upload preset: to use this feature, you first need to enable unsigned uploading for your Cloudinary product environment from the Upload page of your Cloudinary.

An upload preset is used to define which upload options will be applied to media assets that are uploaded unsigned with that preset specified. You can edit the preset at any point in time (or create additional upload presets).

Upload options

You can pass any extra upload parameters you'd want to pass, as part of the upload request. For example, to implement an unsigned upload of an image called imageFile.jpg using an upload preset called sample_preset, and add a tag with the value of sample:

Note
For security reasons, only this restricted set of upload options can be specified directly when performing unsigned upload calls. All other upload parameters can only be specified within the upload preset.

Signed upload

Important

Signed uploads require a signature which needs to be created using your api_secret. You should never expose your secret in client side code and therefore you need to generate an authentication signature on your backend. React Native signed upload with backend support should be implemented in conjunction with one of Cloudinary's backend frameworks (Java, .NET, etc). The various backend frameworks implement helpers to be used in conjunction with React Native, as well as automatically generate the authentication signature for the upload.

To implement signed uploads using React Native to your Cloudinary product environment you must:

  1. Provide a signature generated on your backend.
  2. Include the apiKey configuration parameter in your front end React Native configuration.
  3. Add the signature and timestamp to the upload options.
  4. Call the upload method to upload the file.

For example, to upload an image called imageFile.jpg, set the publicId to newId, and sign the upload request:

✔️ Feedback sent!

Rate this page: