Class: Import::GitlabProjects::FileAcquisitionStrategies::RemoteFileS3
- Inherits:
-
Object
- Object
- Import::GitlabProjects::FileAcquisitionStrategies::RemoteFileS3
- Includes:
- ActiveModel::Validations, Gitlab::Utils::StrongMemoize
- Defined in:
- app/services/import/gitlab_projects/file_acquisition_strategies/remote_file_s3.rb
Constant Summary collapse
- URL_EXPIRATION =
The import itself has a limit of 24h, since the URL is created before the import starts we add an expiration a bit longer to ensure it won’t expire during the import.
28.hours.seconds
Class Method Summary collapse
Instance Method Summary collapse
- #content_length ⇒ Object
- #content_type ⇒ Object
- #file_url ⇒ Object
-
#initialize(params:, current_user: nil) ⇒ RemoteFileS3
constructor
A new instance of RemoteFileS3.
- #project_params ⇒ Object
-
#read_attribute_for_validation(key) ⇒ Object
Make the validated params/methods accessible.
Constructor Details
#initialize(params:, current_user: nil) ⇒ RemoteFileS3
Returns a new instance of RemoteFileS3.
28 29 30 31 |
# File 'app/services/import/gitlab_projects/file_acquisition_strategies/remote_file_s3.rb', line 28 def initialize(params:, current_user: nil) @params = params @current_user = current_user end |
Class Method Details
.allow_local_requests? ⇒ Boolean
10 11 12 |
# File 'app/services/import/gitlab_projects/file_acquisition_strategies/remote_file_s3.rb', line 10 def self.allow_local_requests? ::Gitlab::CurrentSettings.allow_local_requests_from_web_hooks_and_services? end |
Instance Method Details
#content_length ⇒ Object
47 48 49 |
# File 'app/services/import/gitlab_projects/file_acquisition_strategies/remote_file_s3.rb', line 47 def content_length @content_length ||= s3_object&.content_length.to_i end |
#content_type ⇒ Object
43 44 45 |
# File 'app/services/import/gitlab_projects/file_acquisition_strategies/remote_file_s3.rb', line 43 def content_type @content_type ||= s3_object&.content_type end |
#file_url ⇒ Object
39 40 41 |
# File 'app/services/import/gitlab_projects/file_acquisition_strategies/remote_file_s3.rb', line 39 def file_url @file_url ||= s3_object&.presigned_url(:get, expires_in: URL_EXPIRATION.to_i) end |
#project_params ⇒ Object
33 34 35 36 37 |
# File 'app/services/import/gitlab_projects/file_acquisition_strategies/remote_file_s3.rb', line 33 def project_params @project_params ||= { import_export_upload: ::ImportExportUpload.new(remote_import_url: file_url, user: current_user) } end |
#read_attribute_for_validation(key) ⇒ Object
Make the validated params/methods accessible
52 53 54 55 56 |
# File 'app/services/import/gitlab_projects/file_acquisition_strategies/remote_file_s3.rb', line 52 def read_attribute_for_validation(key) return file_url if key == :file_url params[key] end |