# Problem in copying file

**URL:** <https://www.ruby-forum.com/t/problem-in-copying-file/196929>\
**Category:** Rails\
**Created:** [April 6, 2009, 8:55am UTC](https://www.ruby-forum.com/t/problem-in-copying-file/196929 "2009-04-06T08:55:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gandhi-tush](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5daacb/32.png) [@gandhi-tush](https://www.ruby-forum.com/u/gandhi-tush)\
**Post date:** [April 6, 2009, 8:55am UTC](https://www.ruby-forum.com/t/problem-in-copying-file/196929/1 "2009-04-06T08:55:08Z")

</div>

Hi,  
I am facing a problem to copy the file.

I am getting path of the file like this  
“[http://photos-d.ak.fbcdn.net/photos-ak-snc1/v2574/90/75/704291251/457931\_8289306.jpg](http://photos-d.ak.fbcdn.net/photos-ak-snc1/v2574/90/75/704291251/457931_8289306.jpg)”.  
I want to copy this file locally. I am trying to do this by using

File.copy(“[http://photos-d.ak.fbcdn.net/photos-ak-snc1/v2574/90/75/704291251/457931\_8289306.jpg","/images](http://photos-d.ak.fbcdn.net/photos-ak-snc1/v2574/90/75/704291251/457931_8289306.jpg%22,%22/images)”);

I am getting an error  
Invalid argument -  
[http://photos-d.ak.fbcdn.net/photos-ak-snc1/v2574/90/75/704291251/457931\_8289306.jpg](http://photos-d.ak.fbcdn.net/photos-ak-snc1/v2574/90/75/704291251/457931_8289306.jpg)

I know that this is not a directory path. Is any one knows how to copy  
this file?

Thanks  
Tushar

---

<div class="post-metadata">

**Author:** ![gandhi-tush](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5daacb/32.png) [@gandhi-tush](https://www.ruby-forum.com/u/gandhi-tush)\
**Post date:** [April 6, 2009, 9:45am UTC](https://www.ruby-forum.com/t/problem-in-copying-file/196929/2 "2009-04-06T09:45:41Z")

</div>

On Apr 6, 7:55 am, Tushar G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Invalid argument -[http://photos-d.ak.fbcdn.net/photos-ak-snc1/v2574/90/75/704291251/457](http://photos-d.ak.fbcdn.net/photos-ak-snc1/v2574/90/75/704291251/457)…
> 
> I know that this is not a directory path. Is any one knows how to copy  
> this file?

File.copy only understands paths to files on your machine. To get one  
from an http url you need to use net/http, openuri etc.

Fred
