Skip to content

Commit

Permalink
Add S3#put_object with body : String
Browse files Browse the repository at this point in the history
  • Loading branch information
jgaskins committed May 21, 2021
1 parent 8f6c27e commit 8433626
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/s3.cr
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,18 @@ module AWS
)

unless response.success?
raise Exception.new("S3 PutObject returned HTTP status #{response.status}")
raise Exception.new("S3 PutObject returned HTTP status #{response.status}: #{XML.parse(response.body).to_xml}")
end

response
end

def put_object(bucket_name : String, key : String, headers : HTTP::Headers, body : String)
put_object bucket_name,
key: key,
headers: HTTP::Headers { "Content-Length" => body.bytesize.to_s }
.tap(&.merge!(headers)),
body: IO::Memory.new(body)
end

def delete_object(bucket_name : String, key : String)
Expand Down

0 comments on commit 8433626

Please sign in to comment.