Skip to main content
Language

From Remote URL

PhotoEditor SDK supports loading photo files from a remote URL, this can be a resource hosted by a photo hosting provider such as Vimeo or Wistia or your own servers.

Download the photo file#

Although you can pass a URL directly to the editor, we strongly recommend that you manage to download the remote resource yourself. This allows you more control over where and how the download task is being executed and avoids potential problems around UI locking.

Hence we create a download task and upon successful download instantiate a Data object from the downloadURL which is a local URL pointing to the downloaded file.

To save memory you can also save the file to disk instead of keeping it in memory. For an example of how to do this, see the guide on opening a video from a remote URL.

Initialize the editor#

When the download is finished, we hand off to the main queue to initialize a Photo from the data object and pass it as photoAsset to the PhotoEditViewController to instantiate the photo editor. Setting the current class as the delegate of the PhotoEditViewController allows us to implement export, cancellation and error handling there.

Handling user interaction#

While the download task is executing we disable user interaction. In production, you might want to indicate download progress here.

When the download finished, we can reenable user interaction and dismiss the progress indicator.