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 |
# File 'app/services/import/gitlab_projects/file_acquisition_strategies/remote_file_s3.rb', line 28 def initialize(params:, current_user: nil) @params = params 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
46 47 48 |
# File 'app/services/import/gitlab_projects/file_acquisition_strategies/remote_file_s3.rb', line 46 def content_length @content_length ||= s3_object&.content_length.to_i end |
#content_type ⇒ Object
42 43 44 |
# File 'app/services/import/gitlab_projects/file_acquisition_strategies/remote_file_s3.rb', line 42 def content_type @content_type ||= s3_object&.content_type end |
#file_url ⇒ Object
38 39 40 |
# File 'app/services/import/gitlab_projects/file_acquisition_strategies/remote_file_s3.rb', line 38 def file_url @file_url ||= s3_object&.presigned_url(:get, expires_in: URL_EXPIRATION.to_i) end |
#project_params ⇒ Object
32 33 34 35 36 |
# File 'app/services/import/gitlab_projects/file_acquisition_strategies/remote_file_s3.rb', line 32 def project_params @project_parms ||= { import_export_upload: ::ImportExportUpload.new(remote_import_url: file_url) } end |
#read_attribute_for_validation(key) ⇒ Object
Make the validated params/methods accessible
51 52 53 54 55 |
# File 'app/services/import/gitlab_projects/file_acquisition_strategies/remote_file_s3.rb', line 51 def read_attribute_for_validation(key) return file_url if key == :file_url params[key] end |