Validate image file with carrier wave - ruby-on-rails-3

how do you validate the file type of the image you're uploading using carrierwave? Currently we're using the code:
def extension_white_list
%w(jpg jpeg png)
end
But it just validates the extension. If the user changed the extension of a .gif to .jpeg, this will bypass the validation. Any work around for this?
EDIT
My research shows that I need to check the mime type of the file for this. How do you do this in carrierwave? The documentation for mimetype in the gem is very vague.

The best way I solved this is to use bash command through ruby from this site
Although not the most flexible solution, I find that it works on my situation plus it's the most dependable one.

Related

MacOS/Safari double extensions when using ImageResizer

We are converting large PNG images to JPEG using ImageResizer (https://imageresizing.net/). It's works great with ?format=jpg and they are delivered with the correct content type and all.
When downloading these images they are named image.jpg in all browsers except Safari. Here it asks the user if they want to go with .jpg or with .png. It also saves the images as image.png.jpg which is confusing for some users.
I read something about Content-Disposition header, but I think that's for direct download, not for right click and choosing Save as. I also don't know if it would be possible to add it without creating some kind of middle layer and probably lose performance.
Ideas? Thanks <3
I don't think there is a solution to this, as it is in the browser's control.

JPG, png and gif "This file type is not supported" in joomla 3.2.1

Is it me or is this the new joomla release? It worked fine in 3.2 as far as I remember.
I tried png as well and gif. Different filenames.
For the unbelieving people, Legal extensions is:
bmp,csv,doc,gif,ico,jpg,jpeg,odg,odp,ods,odt,pdf,png,ppt,swf,txt,xcf,xls,BMP,CSV,DOC,GIF,ICO,JPG,JPEG,ODG,ODP,ODS,ODT,PDF,PNG,PPT,SWF,TXT,XCF,XLS
for me
I tried uploading an image named java.jpg like your screenshot and it didn't work, then I tried php.jpg and didn't work as well. The same images with different filenames were uploaded fine, so I suppose it's the filename (java, php) and not the filetype (jpg) causing the error.

Alternative Data Instead of Flash

I have a Flash file which displays a PDF file as a magazine, because the magazine is in Hebrew Google doesn't read it good.
Is there any why to display raw Text instead of the Flash for the search engine crawlers?
I heard you can do that using SWFObject, is that correct? and if so, how?
I need it to be SEO friendly...
Thanks in advance :)
SWFObject is still flash, so you don't really change the situation by using that.
recreate the pdf file in html; replace the .html file for your .pdf file. although there are extremely better ways to do this, if you're simply loading content via Ajax.

Multiple photo upload using struts1

We happened to get requirement to upload the multiple files ( like the gmail attachments ) using struts 1.3.5 and Ajax.
I happened to go thorough lot of resources but no luck.
Can someone shed light on this possibly by suggesting or pointing to some useful resources.
I was also looking for a multiple file upload solution for my struts2 application. Since ajax form submit do not support image submission the only option to use was a hidden iframe strategy. However, i found this wonderful plugin which uploads multiple files withour reloading the page and also shows a cool progress bar. The best thing about this plugin is that it doesn't uses flash and works on IE too. I strongly recommend using this plugin
Donot use taglibrary defined file upload for uploading. You can still use
common- fileupload to handle file upload. By doing this you can dynamically
add one more input type file element below the current input type upload using
javascript. I doubt if there is any way to do this using pure struts 1.3.5 :) .

Rails - creating a system for drag-and-drop download

This is a problem I'm trying to think about how to approach -- I haven't actually started it yet.
What I want to do is create a system where there is a gallery of images. These images can be dropped into a folder or some icon in one part of the screen. Then, the images that have been placed in this folder should be able to be downloaded as a zip.
I was intending to use jQuery to do the drag and drop, probably with some AJAX to accomplish the rest of the stuff, but I'm really just not sure how I would accomplish doing this, or if it's even possible (like if the web application can compress the folder of images).
Also, I'd be programming in Rails 3.
Any ideas?
Sounds like a neat interface. I think jQuery drag and drop is the way to go. Once an image is dropped, trigger an AJAX request GET '/photos/download/#{photo_id}'. This action could then utilize Rails send_file, http://apidock.com/rails/ActionController/Streaming/send_file.
def download
#photo = Photo.find(params[:id])
send_file #photo.image
end