Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cleaning-portalmec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard Fernando Heise Ferreira
cleaning-portalmec
Commits
abe43ce7
Commit
abe43ce7
authored
8 years ago
by
Mateus Rambo Strey
Browse files
Options
Downloads
Patches
Plain Diff
fix tempfile of chunks controller
parent
19509839
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/controllers/v1/learning_objects/chunks_controller.rb
+8
-6
8 additions, 6 deletions
app/controllers/v1/learning_objects/chunks_controller.rb
with
8 additions
and
6 deletions
app/controllers/v1/learning_objects/chunks_controller.rb
+
8
−
6
View file @
abe43ce7
...
...
@@ -41,10 +41,12 @@ class V1::LearningObjects::ChunksController < ApplicationController
##
# Move the temporary Sinatra upload to the chunk file location
def
save_file!
return
nil
unless
chunks_params
[
:file
].
try
(
:tempfile
).
is_a?
Tempfile
# Ensure required paths exist
FileUtils
.
mkpath
(
chunk_file_directory
)
# Move the temporary file upload to the temporary chunk file path
FileUtils
.
mv
(
params
[
:file
]
[
:
tempfile
]
,
chunk_file_path
,
force:
true
)
FileUtils
.
mv
(
chunks_
params
[
:file
]
.
tempfile
,
chunk_file_path
,
force:
true
)
end
##
...
...
@@ -66,31 +68,31 @@ class V1::LearningObjects::ChunksController < ApplicationController
def
valid_mime_type?
mime_types
=
@learning_object
.
object_type
.
mime_types
.
map
(
&
:extension
)
return
true
if
mime_types
.
empty?
mime_types
.
include?
params
[
:flowFilename
].
split
(
'.'
).
last
mime_types
.
include?
chunks_
params
[
:flowFilename
].
split
(
'.'
).
last
end
##
# Determine if this is the last chunk based in parts count.
def
last_chunk?
Dir
[
"
#{
chunk_file_directory
}
/
#{
params
[
:flowFilename
]
}
.part*"
].
count
==
params
[
:flowTotalChunks
].
to_i
Dir
[
"
#{
chunk_file_directory
}
/
#{
chunks_
params
[
:flowFilename
]
}
.part*"
].
count
==
chunks_
params
[
:flowTotalChunks
].
to_i
end
##
# ./tmp/flow/abc-123/upload.txt.part1
def
chunk_file_path
File
.
join
(
chunk_file_directory
,
"
#{
params
[
:flowFilename
]
}
.part
#{
params
[
:flowChunkNumber
]
}
"
)
File
.
join
(
chunk_file_directory
,
"
#{
chunks_
params
[
:flowFilename
]
}
.part
#{
chunks_
params
[
:flowChunkNumber
]
}
"
)
end
##
# ./tmp/flow/abc-123
def
chunk_file_directory
File
.
join
(
'tmp'
,
'flow'
,
params
[
:flowIdentifier
])
File
.
join
(
'tmp'
,
'flow'
,
chunks_
params
[
:flowIdentifier
])
end
##
# /tmp/flow/upload.txt
def
final_file_path
File
.
join
(
final_file_directory
,
params
[
:flowFilename
])
File
.
join
(
final_file_directory
,
chunks_
params
[
:flowFilename
])
end
##
...
...
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