Get filenames for photos from camera rollbrowsing

I would like to retrieve the filenames of photos from the iPhone camera roll. I can get the local id of a photo or collection of photos using the asset.local_id property, but that is a long string of letters and numbers, not the actual filename. I have found nothing in the documentation that would help. There must be a get_filename property that I am missing.

I could get the filenames in the Pythonista 2 and earlier photos module using photos.get_metadata(index).get('filename') but that doesn't work when using the new asset properties of the photos module in Pythonista 2.1.

The orientation of photo was available in the metadata using get('Orientation') but I don't know how to access this using the new photos module.

You're surely right but it is still a copy from the camera roll to a Pythonista memory area (not a file, but is it a difference between a file and an object?) and after that a transfer to FTP.
I think that @billbris hoped a direct transfer from the camera roll file to FTP.

I don't think we have access to the original file, even through objc. Maybe I am wrong -- does someone have an example where you can directly open a full path provided by an asset (in ObjC)? my attempts to do that recently gave me access denied errors.

I follow this for assets of type image (re: photos), however, this method just doesn't work for video.

Yes, I was attempting to open the video using the filename, and then use that binary file object as the direct source of sending it via FTP to the server. Although I can open the video file by name the FTP server says it cannot find the file of the same name.

Did you try the little script I posted just before?
It works
File name is only a name, a string, not a file, thus you can't send it!
your line is just an open, not a read and close thus the file is not yet written.
Thus the file does not exist and your ftp command will give this error.
But my script, as adviced by @JonB , does not need to really write a file before sending it via FTP.
Please try my script with your videos and you'll see the .mov on your server

If you want to work through a file, you need to create the file, that will say write the asset to a file, before it can be opened in read for ftp send.

In summary:

a photo/video of the camera roll is a file which you can read via photos asset into a Pythonista local object, the real name of this file is not the filename value

filename is a metadata of the asset, and just a string in Pythonista

if you want, you can create a Pythonista local file containing the bytes of this object, and you can give to this file any name you want, and by example the filename string

you can send to your ftp server, either directly the object (my script) or a file that you need first to create locally (open for writing, write, close)

Thanks for the input. I used your script from above and I get the same problem that I've grown to expect. It seems that get_image_data only returns the first frame (or something). A file with the correct name is created on the FTP server just as expected, however, the contents are not that of a valid video (.MOV). In fact the file size is approximately 110Kb on my Windows machine and that is rather small for a 30 second video.

This brings me back to the original problem.

I will try copying the video file from the photo assets to a sandbox/local directory and then pass that on to the FTP server.

@billbris sorry, I did not understand your real problem of only one frame, and I did not check the size of my file on FTP server, shame on me

@jonb and one more time, Thanks to the biggest guru of this forum. I'm not sure that I will still try to help here 😢
In my example, I never read a file, I write it, thus I did not get any error, it I agree that only one frame has been written.

@cvp: No problem, I appreciate the time and effort.@jonb: The linked code worked just as advertised. I have no experience, yet, with the real internals of iOS, nor with video files. I'm sure that there is a very good reason why videos are handled so much differently than pictures, but at some level they are all just files. Regardless, the code works and I can incorporate it into my existing solution. Thanks for the mind share!

@ccc: Once I get everything for the video transfer in place, I will let you know. At this point, I have made no attempt at anything other than functionality. Also, of the 1600+ files, only 32 or so are videos. I will post results when I'm finished.

I have the video copy code in my ftp app. It now copies video files (MOV) over ftp to the server and the videos play perfectly.

So, thank you for the pointer. It works.

Two questions:

While attempting to understand the code I found myself stumbling on what was happening with the asset. A group of videos is sent to the script, they are then each processed by standard PHIImageManager into what appears to be an AVAsset rather than a Photos.Asset. I am guessing that is required to get at the video data. What is missing on the server side are the other meta-data (video creation date, etc.) that the AVAsset seems to imply should be there. So, the video data is copied, and nothing else. Ideas on improving this to get everything across, including meta-data.

This seems to work for a block of video assets, it would be nice to have it handle a single video file as well. Other than packing up a single video file asset into a collection (having only one element) and passing that to the script, does anyone understand what is happening in the OS enough to make the sample gist above work for just one file at a time?

Those are picky "wishlist" things, but I am investigation them for completion sake.

Finally, once again, thanks to everyone for their amazing pointers and help.

@billbris Are you willing to publish your code on GitHub? It is easier to debug Python code than English prose. My bet is that it would be easier for folks to add their code to your code rather than start from scratch.