2

I'm trying to save an image with a custom filename with PHPhotoLibrary but it for me is impossible. The filename of image always is IMG_XXX.JPG. I get its filename from photos program.

I don't see the filename in my iPhone.

Billal Begueradj
  • 20,717
  • 43
  • 112
  • 130
Jirson Tavera
  • 1,303
  • 14
  • 18

1 Answers1

0

Filenames within the Photos library are an implementation detail. They're not exactly private, but they aren't there as something for you to mess with or rely on the stability of. (For example, if you grab the underlying image file for an asset, it'll have one name, but that name may change if the user edits that asset in the Photos app or it gets uncached and re-downloaded from iCloud Photo Library.)

You can get a filename when you read an asset from the Photos library, simply as a side effect of being able to get an original file. You're not allowed to set filenames in the Photos library, because Photos manages its own storage.

And of course, if you read an asset's original file and want to save a copy of it somewhere else, you can give that copy whatever filename you want.

rickster
  • 124,678
  • 26
  • 272
  • 326
  • i get the last asset but i don't know what is the step that i'll should do. in others words i don't know how to save a copy of this image with custom filename in photosLibrary – Jirson Tavera Sep 16 '16 at 23:56
  • You can save a copy of an asset to the Photos library using `PHAssetChangeRequest` or `PHAssetCreationRequest` and the original asset image or underlying resources. Whether that copy keeps whatever file name you create it with, though, is out of your control, because file names in the Photos library are an internal implementation detail. – rickster Sep 17 '16 at 00:18