Sha256: 10c9ab4b76da56d396d9406fc1eadf380915146c0fb331a565b555f9793c7a70

Contents?: true

Size: 793 Bytes

Versions: 11

Compression:

Stored size: 793 Bytes

Contents

# frozen_string_literal: true

require 'dato/upload/create_upload_path'

module Dato
  module Upload
    class File
      attr_reader :client, :source, :upload_attributes, :field_attributes

      def initialize(client, source, upload_attributes = {}, field_attributes = {})
        @client = client
        @source = source
        @upload_attributes = upload_attributes
        @field_attributes = field_attributes
      end

      def upload
        upload_path = CreateUploadPath.new(client, source).upload_path

        upload = client.uploads.create(
          upload_attributes.merge(path: upload_path)
        )

        {
          alt: nil,
          title: nil,
          custom_data: {},
        }.merge(field_attributes).merge(upload_id: upload['id'])
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
dato-0.8.0 lib/dato/upload/file.rb
dato-0.7.18 lib/dato/upload/file.rb
dato-0.7.17 lib/dato/upload/file.rb
dato-0.7.16 lib/dato/upload/file.rb
dato-0.7.15 lib/dato/upload/file.rb
dato-0.7.14 lib/dato/upload/file.rb
dato-0.7.13 lib/dato/upload/file.rb
dato-0.7.10 lib/dato/upload/file.rb
dato-0.7.9 lib/dato/upload/file.rb
dato-0.7.8 lib/dato/upload/file.rb
dato-0.7.7 lib/dato/upload/file.rb