blob: 91fa25767580d9e31b5c663af8df78641f8c5ba1 [file] [log] [blame]
#Licensed to the Apache Software Foundation (ASF) under one or more contributor
#license agreements. See the NOTICE.txt file distributed with this work for
#additional information regarding copyright ownership. The ASF licenses this
#file to you under the Apache License, Version 2.0 (the "License"); you may not
#use this file except in compliance with the License. You may obtain a copy of
#the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#License for the specific language governing permissions and limitations under
#the License.
desc 'non-idempotent create or update (post is usually create)'
arg_name '[path] [data]'
command :post,:create do |c|
c.flag [:d,:data], :desc => 'does nothing: for ease of conversion from curl'
c.flag [:f,:file], :must_match => /.*=.*/, :arg_name => 'field_name=file_name', :desc => 'will force multipart upload'
c.action do |global_options,options,args|
help_now! unless args[0]
resource = $context[args[0]]
payload = parse_data(options[:data] || args[1])
if $settings.show_curl?
puts_curl(:post, resource, payload, options[:file])
else
if options[:file]
format_response multipart_upload resource, payload, options[:file]
else
format_response resource.post payload
end
end
end
end