Commit fcff2995 authored by Micaël Bergeron's avatar Micaël Bergeron

further changes after discussions

parent 427f1e59
......@@ -76,4 +76,12 @@ module UploadsActions
def image_or_video?
uploader && uploader.exists? && uploader.image_or_video?
end
def find_model
nil
end
def model
strong_memoize(:model) { find_model }
end
end
......@@ -26,8 +26,4 @@ class Groups::UploadsController < Groups::ApplicationController
def authorize_upload_file!
render_404 unless can?(current_user, :upload_file, group)
end
def model
@model ||= find_model
end
end
......@@ -25,8 +25,4 @@ class Projects::UploadsController < Projects::ApplicationController
Project.find_by_full_path("#{namespace}/#{id}")
end
def model
@model || find_model
end
end
......@@ -28,7 +28,7 @@ class UploadsController < ApplicationController
def find_model
return nil unless params[:id]
@model = upload_model_class.find(params[:id])
upload_model_class.find(params[:id])
end
def authorize_access!
......@@ -81,8 +81,4 @@ class UploadsController < ApplicationController
upload_model_class.uploader_options.has_key?(upload_mount)
end
def model
@model ||= find_model
end
end
......@@ -176,7 +176,7 @@ production: &base
## Uploads (attachments, avatars, etc...)
uploads:
# The location where LFS objects are stored (default: shared/lfs-objects).
# The location where uploads objects are stored (default: public/).
# storage_path: public/
# base_dir: uploads/-/system
object_store:
......
......@@ -93,7 +93,7 @@ The `CarrierWave::Uploader#store_dir` is overriden to
> Note: this concern will automatically include `RecordsUploads::Concern` if not already included.
The `ObjectStorage::Concern` uploader will search for the correct `Upload` in the model's `uploads` relationship to select the correct object store. A basic implementation of the `ObjectStorage:: The `Upload` is mapped using the `RecordsUploads::Concern#upload_path` for each store (LOCAL/REMOTE).
The `ObjectStorage::Concern` uploader will search for the matching `Upload` to select the correct object store. The `Upload` is mapped using `#store_dirs + identifier` for each store (LOCAL/REMOTE).
```ruby
class SongUploader < GitlabUploader
......@@ -114,6 +114,7 @@ end
### Using a mounted uploader
The `ObjectStorage::Concern` will query the `model.<mount>_store` attribute to select the correct object store.
This column must be present in the model schema.
```ruby
class SongUploader < GitlabUploader
......@@ -127,7 +128,7 @@ class Thing < ActiveRecord::Base
mount :theme, SongUploader # we have a great theme song!
def theme_store
super || ObjectStorage::Store::REMOTE # send new files to object store
super || ObjectStorage::Store::LOCAL
end
...
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment