8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/loops_sdk/uploads.rb', line 8
def upload(path:, content_type: nil)
data = File.binread(path)
content_type ||= detect_content_type(data)
validate_content_type!(content_type)
create_response = make_request(
method: :post,
path: "v1/uploads",
body: { contentType: content_type, contentLength: data.bytesize }
)
put_to_presigned_url(create_response["presignedUrl"], data, content_type)
make_request(
method: :post,
path: "v1/uploads/#{create_response["emailAssetId"]}/complete"
)
end
|