Module: UppyUploaderHelper

Included in:
ApplicationHelper
Defined in:
app/helpers/uppy_uploader_helper.rb

Instance Method Summary collapse

Instance Method Details

#file_uploader(options = {}) ⇒ Object

Helper method for general file uploads



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/helpers/uppy_uploader_helper.rb', line 33

def file_uploader(options = {})
  default_options = {
    endpoint: upload_images_path,
    max_files: 5,
    max_file_size: 5 * 1024 * 1024, # 5MB
    allowed_file_types: ['*/*'],
    hidden_field_name: 'upload_ids',
    auto_proceed: false,
    height: 300,
    note: 'Images and PDFs only, up to 5MB each',
    submit_button_text: 'Upload Files',
    form_url: '#',
    form_method: :post,
    form_local: true,
    resource_name: 'upload'
  }

  uppy_uploader(default_options.merge(options))
end

#image_uploader(options = {}) ⇒ Object

Helper method for ImageKit image uploads (multiple images)



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'app/helpers/uppy_uploader_helper.rb', line 99

def image_uploader(options = {})
  default_options = {
    # CRM images endpoint only
    endpoint: upload_images_path,
    max_files: 10,
    max_file_size: 50 * 1024 * 1024, # 50MB
    allowed_file_types: ['image/*'],
    hidden_field_name: 'files[files_list]',
    auto_proceed: false,
    height: 400,
    note: 'Image files only, up to 10MB each',
    submit_button_text: 'Upload Images',
    form_url: { action: :create_multi },
    form_method: :post,
    form_local: true,
    resource_name: 'files',
    manual_submit: false # Auto-submit after upload
  }

  uppy_uploader(default_options.merge(options))
end

#large_file_uploader_s3(options = {}) ⇒ Object

Helper method for large file uploads with S3 mode in existing uploader



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'app/helpers/uppy_uploader_helper.rb', line 150

def large_file_uploader_s3(options = {})
  default_options = {
    endpoint: upload_uploads_path, # Still needed for XHR fallback
    presigned_url_endpoint: presigned_url_uploads_path,
    upload_complete_endpoint: upload_complete_uploads_path,
    max_files: 1,
    max_file_size: 500 * 1024 * 1024, # 500MB
    allowed_file_types: ['*/*'],
    hidden_field_name: 'upload_ids',
    auto_proceed: true,
    height: 400,
    note: 'Large files up to 500MB - uploading directly to cloud storage for better performance',
    submit_button_text: 'Upload File',
    form_url: '#',
    form_method: :post,
    form_local: true,
    resource_name: 'upload',
    mode: 's3' # Use S3 mode
  }

  uppy_uploader(default_options.merge(options))
end

#lead_sketch_uploader(options = {}) ⇒ Object

Helper method for lead form sketch uploads



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/helpers/uppy_uploader_helper.rb', line 54

def lead_sketch_uploader(options = {})
  default_options = {
    # Lead form uploads use the WWW uploads endpoint
    endpoint: upload_www_uploads_path,
    max_files: 10,
    max_file_size: 250 * 1024 * 1024, # 250MB per file to allow large docs/CAD
    # Accept virtually any file except executables
    allowed_file_types: ['*/*'],
    hidden_field_name: 'lead[sketch_drawings]',
    auto_proceed: false,
    height: 200,
    note: 'Attach project filesimages, PDFs, docs, CAD files, or ZIPs',
    submit_button_text: 'Upload Sketches',
    form_url: '#',
    form_method: :post,
    form_local: true,
    resource_name: 'lead',
    category: 'sketch'
  }

  uppy_uploader(default_options.merge(options))
end

#rma_image_uploader(rma, options = {}) ⇒ Object

Helper method specifically for RMA image uploads



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/uppy_uploader_helper.rb', line 8

def rma_image_uploader(rma, options = {})
  default_options = {
    endpoint: upload_uploads_path,
    max_files: 10,
    max_file_size: 10 * 1024 * 1024, # 10MB
    allowed_file_types: ['image/*'],
    hidden_field_name: 'rma[upload_ids]',
    auto_proceed: false,
    height: 400,
    note: 'Image files only, up to 10MB each',
    submit_button_text: 'Upload & Attach Images',
    form_url: do_add_multiple_images_rma_path(rma),
    form_method: :post,
    form_local: true,
    resource_name: 'rma',
    resource_type: 'Rma',
    resource_id: rma.id,
    category: 'photo',
    manual_submit: true
  }

  uppy_uploader(default_options.merge(options))
end

#rma_image_uploader_s3(rma, options = {}) ⇒ Object

Helper method for RMA image uploads with S3 mode in existing uploader



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'app/helpers/uppy_uploader_helper.rb', line 122

def rma_image_uploader_s3(rma, options = {})
  default_options = {
    endpoint: upload_uploads_path, # Still needed for XHR fallback
    presigned_url_endpoint: presigned_url_uploads_path,
    upload_complete_endpoint: upload_complete_uploads_path,
    max_files: 10,
    max_file_size: 10 * 1024 * 1024, # 10MB
    allowed_file_types: ['image/*'],
    hidden_field_name: 'rma[upload_ids]',
    auto_proceed: true, # Auto-upload files immediately when dropped
    height: 400,
    note: 'Drop images here - they will upload automatically to cloud storage',
    submit_button_text: 'Upload & Attach Images', # Not used since manual_submit: false
    form_url: do_add_multiple_images_rma_path(rma),
    form_method: :post,
    form_local: true,
    resource_name: 'rma',
    resource_type: 'Rma',
    resource_id: rma.id,
    category: 'photo',
    manual_submit: false, # Auto-submit after upload
    mode: 's3' # Use S3 mode
  }

  uppy_uploader(default_options.merge(options))
end

#uppy_uploader(options = {}) ⇒ Object

Helper method to render the uppy uploader with sensible defaults



3
4
5
# File 'app/helpers/uppy_uploader_helper.rb', line 3

def uppy_uploader(options = {})
  render 'shared/uppy_uploader', options
end

#video_uploader(options = {}) ⇒ Object

Helper method for video uploads



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'app/helpers/uppy_uploader_helper.rb', line 78

def video_uploader(options = {})
  default_options = {
    endpoint: cf_upload_videos_path,
    max_files: 1,
    max_file_size: 100 * 1024 * 1024, # 100MB
    allowed_file_types: ['video/*'],
    hidden_field_name: 'video[cloudflare_uid]',
    auto_proceed: true,
    height: 400,
    note: 'Video files only, up to 100MB',
    submit_button_text: 'Upload Video',
    form_url: '#',
    form_method: :post,
    form_local: true,
    resource_name: 'video'
  }

  uppy_uploader(default_options.merge(options))
end