Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
RDMS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
researchdata
RDMS
Commits
ecd2dc31
Commit
ecd2dc31
authored
1 year ago
by
Gyan Gupta
Browse files
Options
Downloads
Patches
Plain Diff
Added restriction in uploading file
parent
15c541d9
Branches
fix/add_restriction_for_upload_file
Branches containing commit
Tags
Tags containing commit
1 merge request
!239
Added restriction in uploading file
Pipeline
#11736
failed
1 year ago
Stage: build
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hyrax/app/models/hyrax/uploaded_file.rb
+13
-1
13 additions, 1 deletion
hyrax/app/models/hyrax/uploaded_file.rb
hyrax/config/restricted_files.yml
+5
-0
5 additions, 0 deletions
hyrax/config/restricted_files.yml
with
18 additions
and
1 deletion
hyrax/app/models/hyrax/uploaded_file.rb
+
13
−
1
View file @
ecd2dc31
...
...
@@ -15,7 +15,9 @@ module Hyrax
belongs_to
:user
,
class_name:
'::User'
before_create
:set_characterization_data
##
validate
:uploaded_file_name
,
on: :create
##
# Associate a {FileSet} with this uploaded file.
#
# @param [Hyrax::Resource, ActiveFedora::Base] file_set
...
...
@@ -44,5 +46,15 @@ module Hyrax
self
.
characterization_data
[
:file_size
]
=
file
.
size
self
.
characterization_data
[
:original_checksum
]
=
Digest
::
SHA1
.
file
(
file
.
path
).
to_s
end
def
uploaded_file_name
parsed_file
=
YAML
.
load_file
(
Rails
.
root
.
join
(
'config'
,
'restricted_files.yml'
))
file_name
=
file
.
file
.
original_filename
if
parsed_file
[
'restricted_file_names'
].
include?
(
file_name
.
gsub
(
/[\s_\-]/
,
''
).
downcase
)
||
file_name
.
start_with?
(
'.'
)
errors
.
add
(
:base
,
"This file name is restricted."
)
end
end
end
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
hyrax/config/restricted_files.yml
0 → 100644
+
5
−
0
View file @
ecd2dc31
restricted_file_names
:
-
metadata.json
-
meta.json
-
.DS_Store
-
desktop.ini
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment