I am going to develop an app that will basically work as a catalogue for the photos taken from an iPhone app (saved in photo library). I am thinking about creating an SQLite database (catalogue) and mapping it to photos in the photo library (correct me if this approach is wrong).
What would be the best way to map the photos and the SQLite database?
I want to avoid the case that user changes name of the file and link between file and DB doesn't work anymore.
You can store photos in Base63 string into your SQLite database.
And for the Unique identifier of photos you can user imagename_curentUnixTimestamp.jpg.
you can use current date and time to give a name of photo and store it document directory.
also save name of photo into database.when required load photo from document directory as per it's name stored in db.
Related
So I have a image which I get from my server. I want to save that image locally. I have already considered using Userdefaults or Core Data for this instead, but I want the user to be able to see and view the photos from their photos app. So I have a saved photo which is saved using UIImageWriteToSavedPhotosAlbum. How do I later retrieve that same image in my app? This includes even after the app is closed and relaunched.
Are you using the PHPhotoLibrary framework? If so, you can use PHFetchOptions to fetch the photos that were saved by your application. Enter parameters such as album name to retrieve the photos you have saved.
If you have the url of the image being stored using UIImageWriteToSavedPhotosAlbum then use that url to retrieve that image using FileManager API.
Get image from documents directory swift
I have a macOS Photos extension where I update the metadata for the photo. The metadata (location information) is saved correctly, but the Photos application does not recognise the changes since it seems like it is storing its own location information about the photos separately from the photo itself. If I manually export the photo from Photos and re-import it, the location is properly shown in Photos.
Is there a way (in Swift) to trigger a reload of the metadata or to re-import the photo into Photos?
I have scenario that I would like to have all video, uploded from my user account in TableView . I don't want other video. I know about to get the video using searching keyword. But I want it which are uploaded through my account only.
I passed through many things and search on it but can't get it.
You can use flag variable which is set to true when video is uploaded from your account. And when you request for list of video pass the parameter to send list of only uploaded videos.
When I read your question I wonder 3 things:
What type of account are you referring to?
To where is the video uploaded, and how?
Do I make a correct guess if I assume that you are developing an application from where users can log in and upload videos to some kind of service?
Assuming the answer to 3 is YES, then here is a suggested answer to your question:
Create an SQLite Database in your app with a table called "Videos" or such. Let that table have columns for video ID, name, length, date uploaded and any other information that can be useful in your app. Whenever the user uploads a video from your app, insert a new row in your SQlite table with information about that video.
This table should contain the information that you need to show in the TableView of your app. When the user clicks a video or if you need to do other things like showing a thumbnail, load the video from the iPhone using ID or name stored in the table.
phonegap's camera API has this iphone quirk noted:
When destinationType.FILE_URI is used, photos are saved in the application's temporary directory.
details here
and when I load the photo from album, I get imageURI like this
file://localhost/var/folders/sV/sVG0cyUrFvKs6+6I16IO+U+++TI/-Tmp-/photo_007.jpg
and every time I get a different URI for the same photo. Is it possible to get the URI of the original photo file instead of the temporary copy? I need to have the image URI and display multiple photos on the same screen.
Thanks for your help.
Actually it is not possible on iOS as the photos are stored in an area that is not accessible via URL. We need to copy the image to the application specific temp directory so it will be readable by your app.
I am trying to count total photos on the iphone and get the total filesize. What is the best way?
At least in 2.x SDKs, you can't access actual photo files programmatically from code. However, you can access thumbnails of photos which you can use to get a count of photos.
Original photo themselves are in a special database file (/private/var/mobile/Media/Photos/Photo Database) and thumbnail pictures are in a directory (/private/var/mobile/Media/Photos/Thumbs).
Photos can be accessed only through interactive UIImagePickerController. Reverse engineering Photo Database file format is the only way I can see that would give you an access to original photo files programmatically.
I haven't checked the situation for 3.0 SDK, it might give you some API to access photos programmatically.