[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

File copy

Tushar Gandhi

4/6/2009 6:53:00 AM

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....
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...,"/images");

I am getting an error
Invalid argument -
http://photos-d.ak.fbcdn.net/photos-ak-snc1/v2574/90/75/704291251/457931_8...

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

Thanks
Tushar
--
Posted via http://www.ruby-....

10 Answers

Raveendran Jazzez

4/6/2009 7:18:00 AM

0


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

Hi Gandhi,

Try this code which is mentioned in my blog

http://raveendran.wor.../2009/04/06/save-images-fro...


Regards,
P.Raveendran
http://raveendran.wor...
--
Posted via http://www.ruby-....

Tushar Gandhi

4/6/2009 7:58:00 AM

0

Hi,

I write the code like this
"
browser=Watir::IE.new
browser.visible=false
browser.goto(params[:photo_url])

idx = 0

# using the images collection, iterate through all of the images on
a page
browser.images.each do |x|
idx += 1
# apparently the string accepted by the string method will not
allow variable substitution
original_type= x.src[-4,4]
type=".gif" if original_type == ".gif"
type=".jpg" if original_type == ".jpg"
type=".png"if original_type == ".png"
type=".bmp" if original_type == ".bmp"
type="jpeg" if original_type == ".jpeg"
x.save('/images/')
end
"
I am getting an error

" The AutoIt dll must be correctly registered for this feature to work
properly "
How to resolve this?
Thanks,
Tushar

jazzez ravi wrote:
>
>> I know that this is not a directory path. Is any one knows how to copy
>> this file?
>
> Hi Gandhi,
>
> Try this code which is mentioned in my blog
>
> http://raveendran.wor.../2009/04/06/save-images-fro...
>
>
> Regards,
> P.Raveendran
> http://raveendran.wor...

--
Posted via http://www.ruby-....

Loga Ganesan

4/6/2009 7:59:00 AM

0

Tushar Gandhi wrote:
> 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....
> 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...,"/images");
>
> I am getting an error
> Invalid argument -
> http://photos-d.ak.fbcdn.net/photos-ak-snc1/v2574/90/75/704291251/457931_8...
>
> I know that this is not a directory path. Is any one knows how to copy
> this file?
>
> Thanks
> Tushar


Why can't you use wget command in system or popen to download it ?
It's my suggestion
--
Posted via http://www.ruby-....

Raveendran Jazzez

4/6/2009 8:08:00 AM

0

Tushar Gandhi wrote:

> browser.goto(params[:photo_url])

Hi Gandhi,


Oops. please try with separate .rb file first.

After that try to implement in rails.

Regards,
P.Raveendran
http://raveendran.wor...


--
Posted via http://www.ruby-....

Tushar Gandhi

4/6/2009 8:10:00 AM

0

Hi,
I went through this link
http://www.mail-archive.com/wtr-general@rubyforge.org/msg...
and my dll registered successfully.
I changed my code like this
"
browser=Watir::IE.new
browser.visible=true
browser.goto(params[:photo_url])

idx = 0

# using the images collection, iterate through all of the images on
a page
browser.images.each do |x|
idx += 1
# apparently the string accepted by the string method will not
allow variable substitution
original_type= x.src[-4,4]
type=".gif" if original_type == ".gif"
type=".jpg" if original_type == ".jpg"
type=".png"if original_type == ".png"
type=".bmp" if original_type == ".bmp"
type="jpeg" if original_type == ".jpeg"
x.save('E:\Rails2.2\integrateSNS\public\images')
end
"
It open a new tab and open that image and also open windows standard sve
pop up and hangs.
What should I do for this?

Thanks,
Tushar
--
Posted via http://www.ruby-....

Raveendran Jazzez

4/6/2009 8:18:00 AM

0

Hi Gandhi,

Please try to run the code in separate .rb file. Update here in case you
get any errors.


--
Posted via http://www.ruby-....

lasitha

4/6/2009 3:46:00 PM

0

On Mon, Apr 6, 2009 at 12:23 PM, Tushar Gandhi <gandhi.tush@gmail.com> wrote:
> Hi,
>
> File.copy("http://photos-d.ak.fbcdn.net/photos-ak-snc1/v2574/90/75/704291251/457931_8289306.jpg","/im...);
>

Hello Tushar,

Take a look at 'net/http', which is included in the ruby standard library:
http://ruby-doc.org/core-1.9/classes/Net...

For example the following code will download and save the ruby logo
off ruby-lang.org:

require 'net/http'
uri = URI.parse('http://www.ruby-lang.org/images/log...)
Net::HTTP.get_response(uri) do |response|
File.open('/tmp/logo.gif', 'w') {|f| f.write response.body }
end

There are various other ways to go about doing this - some of which
have been mentioned above - but 'net/http' is a good place to start.

solidarity,
lasitha.

Jesús Gabriel y Galán

4/6/2009 4:32:00 PM

0

On Mon, Apr 6, 2009 at 5:45 PM, lasitha <lasitha.ranatunga@gmail.com> wrote:
> On Mon, Apr 6, 2009 at 12:23 PM, Tushar Gandhi <gandhi.tush@gmail.com> wrote:
>> Hi,
>>
>> File.copy("http://photos-d.ak.fbcdn.net/photos-ak-snc1/v2574/90/75/704291251/457931_8289306.jpg","/im...);
>>
>
> Hello Tushar,
>
> Take a look at 'net/http', which is included in the ruby standard library:
> http://ruby-doc.org/core-1.9/classes/Net...
>
> For example the following code will download and save the ruby logo
> off ruby-lang.org:

Another possibility:

irb(main):001:0> require 'open-uri'
=> true
irb(main):003:0> open("http://www.ruby-lang.org/images/logo...) do |f|
irb(main):004:1* File.open("logo.gif", "w"){|out| out.write f.read}
irb(main):005:1> end


Regards,

Jesus.



>
>

Acephale Lemar

12/29/2012 2:36:00 PM

0

choro wrote:

> *sct muhtara ihtiyaci olmayan muhtar bir kurulu$tur*. Ne beyin yikama
> sahasidir, ne de bu entropi mentropi ile ilgilidir. $ahsi goru$um
> sudur ki birbirimize biraz daha tolaransli davranip birbirimizi
> anlamaga cali$makle buralari daha verimli bir sahaya cevirebiliriz.
> Fakat eninde sonunda dunyanin gidi$atini sct'de yazdiklarimizla
> degistirecek degiliz. Dolayisi ile burada yazilanlar uzerinde
> durmamiz bir bakima Hoca'nin gole bir canak yogurt calmasina benzer.
> Eninde sonunda sct'de olan bir avuc ki$inin burada fikir teatisinde
> bulunmasidir.

Sen de inciler d?km?ss?n meydana, bakalim kim toplayacak. Katiliyorum.

Rifat Albayrak

12/29/2012 2:57:00 PM

0

On Sat, 29 Dec 2012 11:21:45 +0000, choro <choro@tvco.net> wrote:

>On 29/12/2012 08:54, Rifat Albayrak wrote:
>> On Sat, 29 Dec 2012 06:34:23 +0000, choro <choro@tvco.net> wrote:

>>> Yine Usenet'den bir alinti...

>>>> USENET is DEAD! Dead and buried by Google, Facebook, Twitter and all
>>> the other mindless propaganda sites designed to steer the public from
>>> any critical thinking and into discussing meaningless drivel instead.<

>>> Merak ediyorum acaba sct'de fikir teatisini onlemeye cabaliyanlarin
>>> amaci veya amaclari ne diye!

>> Fikir al??veri?i ba?ka ?ey, kendi g?r??lerinin yahut bir yerlerden
>> gelen tavsiye ve emirlerin propagandalar?n? yapmak daha ba?ka.
>> Arada fark var.
>> Dedi?in gibi olsayd? fikirlerde bir entropi g?r?lebilirdi. Yirmi sene
>> oluyor, el insaf! Yirmi senedir tek bir kelime girmedi, i?lemedi baz?
>> kafalara.

>> Yirmi sene deyince seni sct de ilk g?r???m geldi akl?ma. Bana hemen
>> Yunanl?larla tak?ld???m a??z dala??n? kesmemi, bunda b?yle bu dala??
>> senin y?r?tece?ini (hem ?ng., hem Yunanca bildi?ini ima ederek)
>> s?ylemendi. Eh verdi?in m?cadeleyi de g?rd?k i?te: "Evet sen hakl?s?n
>> Mehmet, fakat sen de hakl?s?n Alex!" tarz?nda bir ?eyler. :-) Seni bu
>> t?r bir davran???n i?ine iten nedir? Belki de bunun cevab? senin ?u
>> "Ben bu t?r m?zi?i hi? sevmiyorum!" da yat?yor.
>> Sevmezsen sevme birader, burada sadece sen bulunmuyorsun ki?

>Her $eyi siyah beyaz gormekten vazgecmeni tavsiye ediyorum.

En nefret etti?im ?eydir hayat?mda meseleye siyah beyaz bakmak.
O y?zden vicdan?m ve kalbim rahat. Sen kendi problemlerine bak biraz.

>Siyasette arzu ettigin noktaya hep hayir diyerek, kar$indakine saldirarak
>eri$emezsin. Bircok defalar gayene "evet... fakat..." diyerek daha
>suratle ula$abilirsin. Turk Yunan ili$kileri konusunda sen cekil kenara
>da bu konuyu ben kendim yurutecegim diye algilanacak her hangi bir $ey
>yazdigimi hatirlamiyorum. Ne kumes horozu olmaga hevesim vardi ne de
>oyle bir $ey her hangi bir gun aklimdan gecmi$tir.

G?rd?k i?te senin ?u "evet... fakat..." takti?ini. Sadece burada de?il
Yunan Grubunda bile on ki?iden alt?s? sana cevap verme?e l?zum
g?rmezdi. (Son bir sene hi? bakmad?m o gruba. Fakat bir ?eyler
de?i?ti?i, ya da senin oraya yaz?p yazmad???n hakk?nda bir fikrim
yok.)
?imdi o "kenara ?ekil" mevzuunda beni aratt?rma bo? yere. 'Mot a mot'
olmasa bile anlam bab?ndan bana bunu s?yledin. Google un ar?ivinden
mesaj aramay? hi? sevmem. Sevmeyi b?rak bilmem bile. Zira son
zamanlarda epey de?i?tirdiler. Deli gibi ?? g?n msg. arama?a hi?
niyetim yok. Zaten msg. ? bulup g?z?ne soksam bile "Yok ben onu
demek istemedim ?unu demek istedim.." polemi?i haz?r, bekliyor. :-)

>Biliyorum buraya link'ini koydugun o sarkinin ho$uma gitmedigini
>yazmamdan pek alindin fakat ben o tur muzigi begenmem demekle
>ba$kalarinin da begenmemesi gerektigini ima etmi$ olur olmam ki.

Hay?r asla al?nmad?m. Bana ne? Zevkler ve renkler meselesi. Fakat
akl?ma senin ?u "...sen kenara ?ekil.." tavr?n geldi fakat bir ?ey
demedim. Bir sonraki "Usenet ?ld?.." mesaj?nda art?k bundan bahsetmek
farz oldu.

>Ille de Zeki Muren hayrani mi olmali herkes? Bazilarimiz Munir Nurettin
>hayranidir. Bazilarimiz ise ne birinden ne de digerinden ho$lanir fakat
>Turk halk muzigine bayilir.

Bo? yere konu?uyorsun.
Ben o g?n?n m?zi?i ba?l?kl? yaz?lar? senin i?in yazm?yorum, umuma
yaz?yorum.

>*sct muhtara ihtiyaci olmayan muhtar bir kurulu$tur*. Ne beyin yikama
>sahasidir, ne de bu entropi mentropi ile ilgilidir.

Neden ilgili olmas?n? ??ine geldi?inde daha ?nce bilmedi?in bir ?eyi
al?p hazmediyorsun ya? O da bir ?eyin senin kafan? etkilemesi, bir
nevi entropi.
Evet beyin y?kama sahas? de?il ama en az on y?ld?r yazan bir veya
iki kullan?c?m?z var i?ba??nda. Devaml? beyin y?kama pe?indeler.
Eskiden Hakk? da vard? fakat o yeni ?ay?rlara gitti.

>$ahsi goru$um sudur
>ki birbirimize biraz daha tolaransli davranip birbirimizi anlamaga
>cali$makle buralari daha verimli bir sahaya cevirebiliriz.

"Evet fakat.." takti?i ile y?r?mez bunlar. Kar??ndaki seni ???nc?
mesaj?ndan sonra anlayacak ve ona g?re hareket edecektir. Belki
de bir konuda "hakem, hakim olmak", kendini di?erlerinden daha
?st?n g?rmek gibi bir problemin var. Kimbilir?

>Fakat eninde
>sonunda dunyanin gidi$atini sct'de yazdiklarimizla degistirecek degiliz.
>Dolayisi ile burada yazilanlar uzerinde durmamiz bir bakima Hoca'nin
>gole bir canak yogurt calmasina benzer. Eninde sonunda sct'de olan bir
>avuc ki$inin burada fikir teatisinde bulunmasidir.