Method: S3Assets::Utility#json

Defined in:
lib/s3_assets/utility.rb

#json(doc, type: nil, processing: nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/s3_assets/utility.rb', line 4

def json(doc, type: nil, processing: nil)
  file_url = url(doc, type: type, processing: processing)
  return if file_url.blank?

  if doc.present? && doc.processed?
    filepath = doc.asset.path
    content_type = doc.content_type
  end
  {
    id: doc.try(:_id),
    url: file_url,
    filepath: filepath,
    content_type: content_type,
    name: doc.try(:original_filename)
  }
end