Files and Images - GetStream/stream-swift GitHub Wiki

Upload

// uploading an `UIImage` as PNG data
Client.shared.upload(image: File(name: "image.png", pngImage: image)) { result in /* ... */ }

// uploading an `UIImage` as JPEG data
Client.shared.upload(image: File(name: "image.jpg", jpegImage: image, compressionQuality: 0.9)) { result in /* ... */ }

// uploading a file
Client.shared.upload(file: File(name: "file", data: fileData)) { result in /* ... */ }

Delete

// deleting an image using the url returned by the APIs
Client.shared.delete(imageURL: imageURL) { result in /* ... */ }

// deleting a file using the url returned by the APIs
Client.shared.delete(fileURL: fileURL) { result in /* ... */ }

Process images

// create a 50x50 thumbnail and crop from center.
// `ImageProcess` has the `crop` parameter as `.center` by default.
Client.shared.resizeImage(imageProcess: ImageProcess(url: url, resize: .crop, width: 50, height: 50)) { result in /* ... */ }

// create a 50x50 thumbnail using clipping (keeps aspect ratio).
// `ImageProcess` has the `resize` parameter as `.clip` by default.
Client.shared.resizeImage(imageProcess: ImageProcess(url: url, width: 50, height: 50)) { result in /* ... */ }