Method: Fastlane::Helper::S3ClientHelper#upload_file

Defined in:
fastlane/lib/fastlane/helper/s3_client_helper.rb

#upload_file(bucket_name, file_name, file_data, acl) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'fastlane/lib/fastlane/helper/s3_client_helper.rb', line 20

def upload_file(bucket_name, file_name, file_data, acl)
  bucket = find_bucket!(bucket_name)
  details = {
    acl: acl,
    key: file_name,
    body: file_data
  }
  obj = bucket.put_object(details)

  # When you enable versioning on a S3 bucket,
  # writing to an object will create an object version
  # instead of replacing the existing object.
  # http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/S3/ObjectVersion.html
  if obj.kind_of?(Aws::S3::ObjectVersion)
    obj = obj.object
  end

  # Return public url
  obj.public_url.to_s
end