class Dato::Upload::File

Attributes

client[R]
field_attributes[R]
source[R]
upload_attributes[R]

Public Class Methods

new(client, source, upload_attributes = {}, field_attributes = {}) click to toggle source
# File lib/dato/upload/file.rb, line 10
def initialize(client, source, upload_attributes = {}, field_attributes = {})
  @client = client
  @source = source
  @upload_attributes = upload_attributes
  @field_attributes = field_attributes
end

Public Instance Methods

upload() click to toggle source
# File lib/dato/upload/file.rb, line 17
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