I'm using AlamofireImage to download images from the web.
But when i use the images later it downloads the images again and it don't work if my app is offline. Is there a way to save the downloaded images from the web in my app?
This is the code i use:
imageView.af_setImageWithURL(URL, placeholderImage: nil, imageTransition: .CrossDissolve(0.25))
Thank you in advance
I found the error.
The headers from the image request had no cache policy.
Related
I'm quite new to addons development on Firefox.
I need to store an image from a given url, and then get the path to upload on another web. I read the Mozilla docs but can't figure how to do this.
I appreciate any help.
This does exactly what you need: How to download image to desktop with OS.File - you download the image with XHR, you then write that data to anywhere you want with OS.File.writeAtomic Instead of that XHR function, because you are using the SDK you should use the request module - https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/request
I'm trying to build a E-commerce site with a admin page where the administrator can upload images of certain products.
I'd like Meteor to upload those images to a folder and then display those images in the product page of that product.
I know that normally the image files that the client will be using should be inside the 'public' folder, but I'd like to know more about what other options I might have.
Also, if I upload a new file to the 'public' folder or if I delete a file in the 'public' folder, the website refreshes itself...and this is good and bad at the same time depending on what effect you are after....
Here are my questions:
What if I create a 'uploads' folder in the server and upload the images to that folder. Would it be possible to display the images inside the 'uploads' folder in the client browser??? How??
Is there a way to use the browser to access the contents of the 'public' folder???
Is there a way to stop the 'reactivity' of the site if changes happen in the 'uploads' folder created?
Is uploading the images to the 'public' folder the best solution available to this problem?
Thank you very much for the help
When dealing with what will likely be a large number of images I like to offload not only the storage but also the processing to a third party.
My go-to app in this situation would be Cloudinary. Here's why:
Storage - I can store the original images outside of my application. A huge benefit to keep images in sync from dev to prod.
CDN - I get the extra benefits of images being quickly loaded from the Cloudinary CDN.
Off-load Processing - All of the processing of images is handled by Cloudinary which doesn't slow down my app as a whole.
Image Manipulation - I can make calls to the original image, calls to just get a thumbnail, and calls to change manipulate, ie :effect => grayscale. So if a 1000x1000px image was uploaded, I can request a 50x50px from Cloudinary that will return the image cropped to that exact size rather than using CSS to shrink a huge image.
Flexibility - I can change the size of images and return that exact size to the app without having to re-upload images. For example, if my product page pulled in thumbs at 40px, I could easily make a call to grab the same image at 50px.
Hope this helps.
http://cloudinary.com/
You can do all of this using the meteor package collectionFS. The package is well documented and you have a variety of options that you can uses for storing the uploaded files. CollectionFS also gives the ability for image manipulation on the upload, such as creating a resized thumbnail.
I realized this question is a bit old.
I had the same problem, one of the solution that works for me is using meteor-upload https://github.com/tomitrescak/meteor-tomi-upload-jquery
Definitely don't store stuff in the public directory - it will slow down starting up the app, and hot code refreshes on image upload could easily cause it to crash once there are a decent number of images in there.
Any of the above solutions with storing images elsewhere would work. One other option is using the peerlibrary:aws-sdk package to upload stuff to S3, which is what I use for several apps and have found to be very clean.
Storing the image as a base64 string in MongoDB is also a method. Useful for posting to APIs and save the worry of having to handle other 3rd Parties.
I'm struggling a bit with the TTImageView because of the cache policy.
I cannot just disable the cache.
I'm looking for a way to know if the image displayed is loaded from the local cache or if it has been retrieved from the network.
Is there a way to do so ? WEll I mean there has to be a way somehow.
Any help appreciated. Thank you.
Check if the image is in the cache like this before you set the url for the TTImageView:
UIImage* image = [[TTURLCache sharedCache] imageForURL:URL];
if image is not nil it means it is in the cache and will come from the cache if you set the url to a TTImageView
I am using TTPhotoViewController to show photo coming from remote repository. If I change the content of the photo on remote repository but still use the same url, on my iPhone client, the original phone will still be shown when load up the TTPhotoViewController. So the image is somehow cached, is there way to not do that?
I also noticed the same problem with one of the TTTableStyledTextItem that have url to an image.
So is there anyway to clear cache or auto refresh if the target image is changed?
Three20 uses an internal cache called TTURLCache that supports all kinds of caches including ETag and such.
Manually disable cache to disk via:
[TTURLCache sharedCache].disableDiskCache = YES;
I wouldn't recommend disabling the cache and instead you should look at your http cache header on your images - Three20 by default is respecting it. One way I do recommend you to handle it is adding a dummy parameter to your image urls (assuming you get the image url through some kind of an api). then simply append a dummy version number to it. Each time the version chages your app will get a new version of the image.
instead of:
http://yoururl.com/image.png
use
http://yoururl.com/image.png?dummyversion=232
I'm trying to make an Image Gallery App using Three20 and what I want to do is get images stored on a webserver and store them in a NSMutalbeArray and display them in thumbnail view.
I've gone through Three20 Photo Gallery tuts but everywhere its either local images or passing links of all images in code. while my problem is Images will be added frequently to the server so its not a good idea to update code and send app update everytime an image is added to the server.
it seems i'll have to use for( ) loop but i don't know how to store images in NSMutableArray and use it in for( ) loop to get all the available images.
please help
I don't really know Three20 but what i can tell you is that you can use ASIHTTPRequest to download the images and store them locally to display them later.
See documentation here
You should be able to implement the <TTPhoto> protocol and provide remote URLs when you define the
- (NSString*)URLForVersion:(TTPhotoVersion)version
method. Have you tried this?