D
D
Dima Grib2019-05-26 15:27:22
Swift
Dima Grib, 2019-05-26 15:27:22

How to implement Temp Directory for Image?

Guys, who faced? How to correctly implement local storage for an image in an application for images and videos that are regularly overwritten and not saved to the camera roll? I need an assetID to repost.

let data = UIImagePNGRepresentation(image!)
let uiImage: UIImage = UIImage(data: data!)!

 do {
    try PHPhotoLibrary.shared().performChangesAndWait {
    let request = PHAssetChangeRequest.creationRequestForAsset(from: uiImage)
    let assetID = request.placeholderForCreatedAsset?.localIdentifier ?? ""
    let shareURL = "instagram://library?LocalIdentifier=" + assetID
                                                
     if UIApplication.shared.canOpenURL(...) {
         if let urlForRedirect = NSURL(string: shareURL) {

         }
     }
     }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
briahas, 2019-05-30
@briahas

- Write to the camera roll
- make a repost
- after any end of the repost event - delete from the camera roll
, yes, for this you will need to request permission to work with Photos, well, well, ask him right before the repost.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question