View: descargar images en disco

  1. 3 years ago by macks
    1. def downloadImage(self):
    2.     img_url = 'http://img1cdn.adoosimg.com/b195d543e38e349deac032b41be043c7-1-5.jpg'
    3.     imgName = 'b195d543e38e349deac032b41be043c7-1-5.jpg'
    4.     imgN = "peque_%s"%imgName.replace('5.','7.') if imgName[-5:]=='5.jpg' else imgName
    5.    
    6.     file_path = "%s/adoos/%s" % (settings.UPLOAD_PATH, imgN)
    7.     downloaded_image = file(file_path, "wb")
    8.  
    9.     image_on_web = urllib.urlopen(img_url)
    10.     while True:
    11.         buf = image_on_web.read(65536)
    12.         if len(buf) == 0:
    13.             break
    14.         downloaded_image.write(buf)
    15.     downloaded_image.close()
    16.     image_on_web.close()
    17.  
    18.     return  file_path
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2073"></script>

0 comment about "descargar images en disco"