Skip to content
Snippets Groups Projects
Commit 45c8319c authored by Giovanne Marcelo's avatar Giovanne Marcelo
Browse files

Merge branch '206-fix-authentication-problem-user-logins-stop-without-user-command' into 'master'

uploading file by chunks now use diferent parameters

See merge request !394
parents 25f35c2a c9cdd3ec
No related branches found
No related tags found
No related merge requests found
...@@ -30,7 +30,17 @@ class V1::LearningObjects::ChunksController < ApplicationController ...@@ -30,7 +30,17 @@ class V1::LearningObjects::ChunksController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through. # Never trust parameters from the scary internet, only allow the white list through.
def chunks_params def chunks_params
params.permit(:id, :file, :flowChunkNumber, :flowTotalChunks, :flowFilename, :flowIdentifier) params.permit(
:id,
:file,
:_chunkNumber,
:_totalChunks,
:_chunkFilename,
:_chunkIdentifier,
:_chunkSize,
:_currentChunkSize,
:_totalSize
)
end end
def post_file! def post_file!
...@@ -68,37 +78,37 @@ class V1::LearningObjects::ChunksController < ApplicationController ...@@ -68,37 +78,37 @@ class V1::LearningObjects::ChunksController < ApplicationController
def valid_mime_type? def valid_mime_type?
mime_types = @learning_object.object_type.mime_types.map(&:extension) mime_types = @learning_object.object_type.mime_types.map(&:extension)
return true if mime_types.empty? return true if mime_types.empty?
mime_types.include? chunks_params[:flowFilename].split('.').last mime_types.include? chunks_params[:_chunkFilename].split('.').last
end end
## ##
# Determine if this is the last chunk based in parts count. # Determine if this is the last chunk based in parts count.
def last_chunk? def last_chunk?
Dir["#{chunk_file_directory}/#{chunks_params[:flowFilename]}.part*"].count == chunks_params[:flowTotalChunks].to_i Dir["#{chunk_file_directory}/#{chunks_params[:_chunkFilename]}.part*"].count == chunks_params[:_totalChunks].to_i
end end
## ##
# ./tmp/flow/abc-123/upload.txt.part1 # ./tmp/file-chunks/abc-123/upload.txt.part1
def chunk_file_path def chunk_file_path
File.join(chunk_file_directory, "#{chunks_params[:flowFilename]}.part#{chunks_params[:flowChunkNumber]}") File.join(chunk_file_directory, "#{chunks_params[:_chunkFilename]}.part#{chunks_params[:_chunkNumber]}")
end end
## ##
# ./tmp/flow/abc-123 # ./tmp/file-chunks/abc-123
def chunk_file_directory def chunk_file_directory
File.join('tmp', 'flow', chunks_params[:flowIdentifier]) File.join('tmp', 'file-chunks', chunks_params[:_chunkIdentifier])
end end
## ##
# /tmp/flow/upload.txt # /tmp/file-chunks/upload.txt
def final_file_path def final_file_path
File.join(final_file_directory, chunks_params[:flowFilename]) File.join(final_file_directory, chunks_params[:_chunkFilename])
end end
## ##
# /tmp/flow # /tmp/file-chunks
def final_file_directory def final_file_directory
File.join('tmp', 'flow') File.join('tmp', 'file-chunks')
end end
## ##
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment