A ruby script that automatically uploads images to another cloud

Source: Internet
Author: User

Require ' Upyun '

Upyun = Upyun::Rest. New (' bucket ', ' operator ', ' password ')

# Local path:./folder/1/2/3.jpg, then, after uploading to the remote, it should be:

# The requirements for executing this script are:

# 1. CD to the destination folder's sibling directory, for example:/opt/app/yuehouse_web/public

# 2. Destination folder (for example, files). Direct:

root ='/users/zhangyu/pictures '

folder = '/files '

Files_and_folders = ' Find #{root + folder}'

Files_and_folders.split ("\ n"). select{| Entity|

Entity.include? ("." )

}.each {| File|

Remote_file_path = File.sub (Root, ")

Puts Upyun.put (remote_file_path, file. New (file))

}

A ruby script that automatically uploads images to another cloud

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.