credentials into the code during the development process, but you can also write to the code without creating the configuration file.Connection EC2:Import Boto.ec2conn = Boto.ec2.connect_to_region ("ap-northeast-1")The above code can be connected to the corresponding area of EC2, please refer to the area code:
Code
name
ap-northeast-1
Asia Pacific Region (Tokyo)
ap-southeast-1
Asia Pacific Region (Singapore)
ap-south
Recently, the latest version of the Ruby 1.9 series, Ruby 1.9.2, has been officially released. This version is compatible with most of 1.9.1. Ruby 1.9.2 99% has passed RubySpec, and Ruby 1.9.2 has significantly improved its performance compared with the 1.8.x series.
Interestingly,
1.Grape is a restful-style ruby micro-framework that runs on rack or in conjunction with Rails/sinatra, simplifying the development of APIs by providing a simple DSL (domain-specific language). It has built-in support for mutiple formats (), Subdomain/prefix restriction, versioning, etc. general constraints (ruby constraints are higher than the configuration). See http://intridea.github.io/grape/.2. Install
1.require ' Upyun ' reference Upyun 2.upyun = Upyun::rest.new (bucket,operator,password,options,endpint)3.res = Upyun.put ('/1/2/3/4/5/hi.jpg ', File. New ('/workspace/hi.jpeg ')) 4.puts "Response is #{res}" Look at the return information if it is a picture information then return is Response is {: height=>212,:file_type=> "JPEG",: width=>238,: Frames=>1}Picture information If the return is true then it will not be the picture space5. More Information HTTPS://GITHUB.COM/UPYUN/
In fact, Ruby Write API program is very simple, if the API itself is relatively standard, rather than a mess.classapidemo# Defining Interfaces API_QERUY=[ :userAdd # User profile Add ]# implement Ghost Method defmethod_missing (method_name , *args,block) API_QERUY.eachdo|v| ifv.to_s==method_name.to_s returnapi_request (V.to_s,args.first) endendsuper end# Returns
Note: The following code is only for the convenience of customer testing and provide the sample code, the customer can according to their own needs to write the code for Learning and research interface only for use, but provides a referenceRequire ' net/http 'Require ' URI 'Require ' JSON 'params = {"Account" = "","Password" = "a.123456",Mobile phone number, format (area code + mobile number), for example: 8615800000000, of which 86 is China's area code"mobile" => "8615800000000", }.to_jsondef
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.