fclay 0.1.32 → 0.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fclay/attachment.rb +21 -18
- data/lib/fclay/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 108744d0ed9af40db54c6f50de1766747560f5cd
|
4
|
+
data.tar.gz: c063c8c9dd569de1c838f3af2cbf63d4f93f74b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00cec2b28094d4c4946c3345f63dc771077328082764b1832cde0f55f2680d65ad923d458cb3f9f9f1887ca2deed60859bf46fac13918b2a03b5563d2a0fb4f7
|
7
|
+
data.tar.gz: c70b0c4f7119ede4cb2b437bc60f5d9bfd40e25918a0ec9bdbb7371d35d0067f8b0c03f7afab29a9deaf7040f867c940a654ddd6dab19b2de36ca8e56e66b358
|
data/lib/fclay/attachment.rb
CHANGED
@@ -44,7 +44,7 @@ module Fclay
|
|
44
44
|
|
45
45
|
def upload_later
|
46
46
|
|
47
|
-
self.try(:log,"upload_later called, need_upload: #{need_upload}")
|
47
|
+
self.try(:log,"upload_later() called, need_upload: #{need_upload}")
|
48
48
|
if need_upload
|
49
49
|
job = Fclay::UploadJob.perform_later(self.class.name,self.id)
|
50
50
|
self.try(:log,"sheduled! job id: #{job.provider_job_id}")
|
@@ -57,27 +57,30 @@ module Fclay
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def self.upload type,id
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
(uploading_object.class.fclay_options[:styles] || [nil]).each do |style|
|
69
|
-
obj = bucket.object(uploading_object.remote_file_path(style))
|
70
|
-
obj.put({
|
71
|
-
body: File.read(uploading_object.local_file_path(style)),
|
72
|
-
acl: "public-read",
|
73
|
-
content_type: uploading_object.class.fclay_options[:content_type]
|
74
|
-
})
|
75
|
-
end
|
60
|
+
self.try(:log,"upload('#{type}',#{id}) called")
|
61
|
+
type = type.safe_constantize
|
62
|
+
return unless type
|
63
|
+
uploading_object = type.find_by_id(id)
|
64
|
+
self.try(:log,"uploading_object: #{uploading_object} uploading_object.need_upload: #{uploading_object.need_upload}")
|
65
|
+
return if !uploading_object || !uploading_object.need_upload
|
66
|
+
content_type = uploading_object.try(:content_type)
|
67
|
+
bucket = Fclay.remote_storage.bucket_object
|
76
68
|
|
77
|
-
|
69
|
+
self.try(:log,"Start uploading")
|
70
|
+
(uploading_object.class.fclay_options[:styles] || [nil]).each do |style|
|
71
|
+
obj = bucket.object(uploading_object.remote_file_path(style))
|
72
|
+
obj.put({
|
73
|
+
body: File.read(uploading_object.local_file_path(style)),
|
74
|
+
acl: "public-read",
|
75
|
+
content_type: uploading_object.class.fclay_options[:content_type]
|
76
|
+
})
|
77
|
+
end
|
78
|
+
|
78
79
|
type.where(:id => id).update_all(:file_status => 'idle', :file_location => Fclay.remote_storage.name)
|
80
|
+
self.try(:log,"Sucessful uploaded! file_status: 'idle', file_location: #{Fclay.remote_storage.name}")
|
79
81
|
uploading_object.delete_local_files
|
80
82
|
uploading_object.try(:uploaded)
|
83
|
+
|
81
84
|
|
82
85
|
end
|
83
86
|
|
data/lib/fclay/version.rb
CHANGED