Module: Pageflow::UploadableFile

Extended by:
ActiveSupport::Concern
Includes:
ReusableFile
Included in:
AudioFile, ImageFile, OtherFile, TextTrackFile, VideoFile
Defined in:
app/models/concerns/pageflow/uploadable_file.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from ReusableFile

#cache_key, #file_type, #nested_files, #original_url, #parent_allows_type_for_nesting, #parent_belongs_to_same_entry, #retry!

Instance Method Details

#attachmentObject



46
47
48
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 46

def attachment
  attachment_on_s3
end

#attachment=(value) ⇒ Object



50
51
52
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 50

def attachment=(value)
  self.attachment_on_s3 = value
end

#attachment_default_urlObject

Overwritten if a file type wants to merge its attachments default_url into Pageflow.config.paperclip_s3_default_options. (See Pageflow::ImageFile for example)



61
62
63
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 61

def attachment_default_url
  ''
end

#attachment_styles(_attachment) ⇒ Object

Overwritten if a file type wants to add additional styles to Pageflow.config.paperclip_s3_default_options. (See Pageflow::ImageFile for example)



68
69
70
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 68

def attachment_styles(_attachment)
  {}
end

#attachments_for_exportObject

ReusableFile-overrides:



74
75
76
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 74

def attachments_for_export
  [attachment]
end

#basenameObject



84
85
86
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 84

def basename
  File.basename(attachment.original_filename, '.*')
end

#can_upload?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 92

def can_upload?
  uploading?
end

#direct_upload_configObject



54
55
56
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 54

def direct_upload_config
  Pageflow.config.paperclip_direct_upload_options.call(attachment)
end

#extensionObject



88
89
90
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 88

def extension
  File.extname(attachment.original_filename).sub(/\A\./, '')
end

#failed?Boolean

Returns:

  • (Boolean)


104
105
106
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 104

def failed?
  uploading_failed?
end

#file_nameObject



42
43
44
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 42

def file_name
  attachment_on_s3_file_name
end

#publish!Object



108
109
110
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 108

def publish!
  file_uploaded!
end

#ready?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 100

def ready?
  attachment.present?
end

#retryable?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 96

def retryable?
  false
end

#urlObject



78
79
80
81
82
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 78

def url
  if attachment.present?
    attachment.url
  end
end