Sha256: aa0f911e58047775b9e0d7f37ca21d8fed8643d1e0a125464de416ecad8556e8

Contents?: true

Size: 794 Bytes

Versions: 3

Compression:

Stored size: 794 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

3 entries across 3 versions & 1 rubygems

Version Path
dato-0.8.3 lib/dato/upload/file.rb
dato-0.8.2 lib/dato/upload/file.rb
dato-0.8.1 lib/dato/upload/file.rb