Skip to main content

Photo Operations

Force Upload#

The force upload function is used to force upload photos/videos to the cloud storage.

It can be used for:

  • Uploading photos/videos to the cloud storage when automatic upload is stopped for some reason (auto upload is disabled, battery power is insufficient, wi-fi is not available, etc.)
  • Skipping an automatic sequential photo/video upload.

When creating an album and/or adding a photo/video to an album, force upload is first automatically applied to the items that have not yet been uploaded to the cloud storage.

Keep in mind that the main purpose of the force upload function is to allow the user to upload specific items from the local gallery to the cloud without having to upload all the content.

To upload items to the cloud, you need to call the following methods:

let cancellable = cloudikePhotosKitInstance.timelineService.forceUploadItems(items, completion: { result in    switch result {    case let .success(items):        print("force upload success")    case let .failure(error):        print("force upload error: \(error)")    }})

The parameters of the forceUploadItems function are as follows:

  • items: [CloudikeMediaItem] - A list of items to force upload.
  • completion: (Swift.Result<[CloudikeMediaItem], Error>) -> () - The completion handler to receive the result and the error objects.

To cancel operation, you can call cancel() on Cancellable that returned by the forceUploadItems() method.

Download Photo#

To download items from the cloud or device gallery, you need to call the following methods:

let cancellable = cloudikePhotosKitInstance.timelineService.download(item: mediaItem, destination: FileManager.default.temporaryDirectory, fileName: nil) { progress in    print("upload progress: \(progress)")} completion: { result in    switch result {    case let .success(url):    print("download success with url: \(url)")    case let .failure(error):    print("download error: \(error)")    }}

The parameters of the download function are as follows:

  • items: CloudikeMediaItem - An item to download.
  • destination: URL - Path to directory in app's sandbox where downloaded file will be stored.
  • fileName: String? - Optional parameter for file stored in app's sandbox.
  • progress: ((Double) -> Void)? - Handler to display download progress.
  • completion: (Swift.Result<URL, Error>) -> () - The completion handler to receive the result URL and the error objects. To cancel operation, you can call cancel() on Cancellable that returned by the download() method.

Delete Photo#

To delete items from Timeline, you need to call the following methods:

photosManager.timelineService.delete(items, completion: { (result) in    switch result {    case .success():        NSLog("Timeline> delete> success")    case let .failure(error):        NSLog("Timeline> delete> error: \(error)")    }})

The parameters of the delete function are as follows:

  • items: [CloudikeMediaItem] - A list of items to remove.
  • completion: (Swift.Result<Void, Error>) -> () - The completion handler to receive the result and the error objects.

Add Photo to Album#

Please refer to Working with Albums. Add Photos to Album

Create Public Link#

Please refer to Working with Albums. Create Public Links

Copy Photo to Family Cloud#

Please refer to Family Cloud. Copy to Family

Get streamable link#

To get a link to a video item, you need to call the following method:

photosManager.timelineService.videoLinkForItem(identifier) { (url) in}

The parameters of the videoLinkForItem function are as follows:

  • identifier: String - The identifier of the item(CloudikeMediaItem.backendID).
  • completion: ((URL?) -> Void)? - The completion handler to receive the result.