How to writing video in gallery without intermediate directory?

I trying create app where user can record video use AVFundation. After video already recorded user can save or discard. Now I write video in temp folder and after move in gallery. But in this case video take x2 memory sometimes. Until it is removed from the staging folder.

I want to record video directly to the gallery without temp/document directory. Is this possible, and how I can do it if yes?

Upvotes: 0

Views: 42

Answers (1)

Frank Rupprecht
Frank Rupprecht

Reputation: 10383

When you move the video to Photos using an PHAssetCreationRequest by using the addResource(with type: PHAssetResourceType, fileURL: URL, options: PHAssetResourceCreationOptions?) method, you can set the shouldMoveFile option to true. From the docs:

If this value is true, Photos moves the specified file into the Photos library to create the asset resource, removing the original file after the asset has been successfully created. When using this option, Photos does not make an intermediary copy of the resource data, so no additional storage space is required.

Upvotes: 1

Related Questions