I was wondering if it was possible to put pictures into DynamoDB tables from an iOS device. If so I was wondering if someone could provide me with an example using the Swift language as I have no idea where to start.
DynamoDB supports attributes of Binary type. You could have an IMAGES table where you store items with an image Binary attribute value. The maximum item size of DynamoDB items is 400KB. If the images you are trying to store are larger, or can be larger than 400KB, then you will not be able to store those images. In case you want to support images larger than 400KB, store S3 links to the images in DynamoDB, and store the actual images in S3. It might be easier to only store links to images in S3.
Yes its possible if the images are small enough - better answer: don't do it. Just because you could, doesn't mean you should.
If you are working in/on the amazon stack, s3 is a much better place to store images.
Related
I am building my flash card iOS app for reviewing my learning Japanese using SwiftUI language.
The problem is how to storing and updating my images(>500 images). Please help me, any suggestion is appreciated, thanks for reading my post.
I think you're asking about how to manage 500+ images in an Xcode project. You could just add all the images to your project and load them as you would any image. You could use asset catalogs, which have the advantage that they let you store different versions of a resource for use on different devices, and only the ones needed for the device the app runs on will actually be installed on the device. See How Many Images Can/Should you Store in xcassets in Xcode? and Asset Catalog Format Reference for more information about asset catalogs. But any way you slice it, managing 500+ images is going to be cumbersome. There's probably a better way...
Managing all those images in your app isn't just a problem for you as the developer; building them into the app will also create problems for the user. Even if each image is relatively small, having hundreds of them in the app will probably make the app huge. That means it'll take a long time to install, and the app will use a lot of storage on the device. Every time you release a new version of the app, with more words, or even just to fix a few small bugs, the user will have to download all that data all over again.
Instead, you should consider building an app that can fetch the data it needs from a server. Ideally, you could apply that approach to all your app's data, not just the images. Maybe you'll organize your flash cards into sets of a few dozen, so that you can fetch a set of cards and the associated images pretty quickly, and sets that the user hasn't used for a while can be removed to free up space on the device. You'll be able to update a set of flash cards without having to update the app, and when you do update the app your users won't have to download all the data all over again.
You've said that you're a beginner, so this approach might seems very difficult. That's OK, you can start with a simpler approach and then improve as you go along. For example, you might just put all the images on a server and fetch them one at a time as you need them. Your flash card data file could contain just a dictionary with words and the URLs associated with those words. There are lots of examples of loading an image from an URL here on SO and elsewhere, so I'm not going to provide code for that, but it won't be hard to find. The earlier you start thinking about how to design your app so that it can scale as you add more and more words, the easier it will be to maintain the app later.
500 images can have a huge size. Applications that published on Appstore have size limit and Apple does not recommend to make big apps.
Store them on server and load needed images on fly. Also you will get possibility to update your images, remove add new.
If you don't have a backend, you can use something easy and free (Firebase storage for example) or with minimal code writing on AWS.
If you need to keep them on device - store them as files in the Documents or another apps folder, do not use CoreData for it (you can keep only the list of names/urls in database).
After loading image to be displayed for user, you can prefetch next bunch of images.
Use Alamofire, or SDWebImage to load images from network (I prefer last). These frameworks can do many useful things with images.
To load images:
you can have a list of your images (just list of the names and urls)
or
you can know only path and names pattern and generate links dynamically (like https://myserver/imageXXX.png.
I am currently trying to build a chat application in swift whilst using Firebase for real-time messaging. My only issue is I want users to send images, I want them to have profiles with images but I know Firebase has limited storage (or at least storage per pay tier is low for the number of connections you get)
So I would like to know how to connect up another database and make calls when needed between the two. So when and image is sent in a message, rather than Firebase storing the image, it stores a URL to the image in the other database.
I am under the impression something like AWS S3 is my best bet. any help is appreciated!
This question has been asked before and there are a number of solutions. It's kind of an 'opinion' type question but here are a few options.
View and store images in Firebase
Firebase has a 10Mb capacity, which is adequate for many images. However, if you need larger, they can be easily encoded as base64 and split into chunks.
If you want to go external:
s3 or Filepicker (Filestack) as well as Google provide some options.
Not sure of the overall requirements but obviously you can dig into CloudKit / CoreData and even Dropbox offers an API.
I have zero experience with Box but it may be an option as well.
Each option has it's own API.
In general, you would store a link in a firebase node to the image/object in question. However, the mechanics of that vary wildly as interfacing with CloudKit/CoreData will be different than say Filepicker.
With CoreData you will have to roll your own reference scheme whereas Filepicker you can have an almost direct reference to the file.
Many of these services provide a free or low cost tryouts and you can whip some code up in a manner of a few minutes to test out the functionality to see if it may meet your requirement.
If you need help encoding/decoding, see the answer to this question
Swift2 retrieving images from Firebase
Once you get rolling, if you have issues post some code in another question.
I am working on an iOS app. Client side is written in Swift.
I want users to be able to store text and images in a local DB, and then transmit the DB records to a server.
I already implemented client-side data storage (but not for image files) using SQLite DB. I know that it is possible to store image files as BLOBs in SQLite, but is it wise to do so? What are your experiences? If SQLite is not the right DB for this use case, what would be better?
This StackOverflow answer discusses why saving an image in a database isn't the greatest idea.
I think the current best practice for saving images on iOS would be to save the image to documents or the photo album, and save the file path to the image in the DB. UIKit has UIImageWriteToSavedPhotosAlbum() which will save the image for you.
OK, I'm new to IOS development but have a decent amount of programming experience so thought it would be fairly straightforward to pick up.
I'm creating a photo app that will display all of the users images (or take new images using camera) and then display them in galleries based on metadata tags.
I've spent a considerable amount of time searching for the best approach but seems nothing is that suitable, I need to be able to easily access the tags as they will be used as criteria for querying the database and populating the galleries.
The problem is that I want to be able to add extra tags to an image or multiple images at any time without having to parse XMP data and storing an entirely new image.
From what i've found so far there should be ways to add tags to my image file using either XMP or EXIF data to store extra strings but they seem to be quite long-winded, I was considering just making a custom data type that would hold an image and an array of strings for the tags but this doesn't seem logical if there is already a specific structure within the image to store such metadata.
Alot of people have mentioned using
WriteImageDataToSavedPhotosAlbum or
CGImageDestinationSetProperties
Ultimately I would just like to know if anybody can clarify how I should access, edit and display the xXMP or EXIF data in my app or just create my own (shoddy looking) data structure that would essentially be image representation + string array of 'tags'
You are looking at using the ALAssetsLibrary framework. This is quite a good tutorial which I have used before :
http://www.altdevblogaday.com/2011/05/26/getting-metadata-from-images-on-ios/
I am solving the question about downloading a large amounts of picture from the web. I have XML file with links to images on web sites and I have to download this images. Every image have ca ±3MB and the count of images is tens of thousands, so is not possible to store these images on hosting (100.000 x 3MB)...
And these images I need to display on sites. I don't worked yet with so large amounts of data yet, so I would like to ask you, what could be the best idea for displaying these images on "my" page.
My first ideas:
- store only links into my database table and then for displaying images use just image_tag URL_OF_IMAGE
- some a way of caching images/links of images (I don't know specifically)
Can you help me, please, what you think will be the fastest way for displaying images from foreigners sources?
Thank you in advance,
M.
Amazon S3, but as ezkl says, make sure you have licensing rights to the images or you'll land yourself in trouble (and in any case it is wrong to use the content without permission).