Question: I'm using ruby 1.9.2 along with Rails 3.1.4 and Paperclip 2.4.5.

My issue is trying to save a paperclip attachment from a URI loses the file extension and saves the file without one resulting in issues with things like fancybox that require an extension.

Some example code:

```
uri = "http://featherfiles.aviary.com/2012-06-13/bbe5f0de1/0c5a672b88ea47ecb4631ac173e27430.png"
open(uri)
#=> #<File:/var/folders/zc/d69gxhzx10x_bvjrkqgyjgxr0000gn/T/open-uri20120613-27204-i6cldv>

```

Because there is no extension on the temp file paperclip is saving the file without one resulting in issues.

Has anyone run into this issue? I've seen multiple answers about using paperclip to store images from a URI but none seem to address the same problem we're running

Answer: 
Don't use the temporary file! It's there as a placeholder as the file is read from the port, and should be considered a private resource for `OpenURI`. Instead, use `open(url).read` and work with the resulting content by saving it.

Do something like:

```
require 'uri'
require 'open-uri'

url = 'http://www.iana.org/domains/example/index.html'
filename = File.basename(URI.parse(url).path)
File.open(filename, 'wb') do |fo|
  fo.write(open(url).read)
end

```

Temporarily spooling to disk during an operation, especially a network operation, is common. Once the file's content has been accumulated, then it is available to be passed off to the app. `read` is blocking, so your code will stop there until the file is returned to you. Then you can play with it.
Im not sure if this will help in your case, but I was noticing similar issues in my project. 

The issue turned out to be not caused by `Paperclip` nor `open-uri`, but the receiver of the paperclip file (in my case `Spree Commerce`). Check that you are assigning the paperclip object to the right object, and that it is being interpreted correctly. 

The fix that worked for me was to change:

```
@product.images << Spree::Image.create({ 
    :attachment => open(image_url) 
}, :without_protection => true)

```

to

```
@product.master.images << Spree::Image.create({ 
    :attachment => open(image_url) 
}, :without_protection => true)

```

Good luck with your issue