From 6104d83f1d06d0e1b26038d76910a6bf8fee97a1 Mon Sep 17 00:00:00 2001 From: jackburr Date: Mon, 1 Feb 2021 22:01:40 +0100 Subject: [PATCH 1/2] Flow JS Handler --- src/Handler/FlowJSUploadHandler.php | 85 +++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/Handler/FlowJSUploadHandler.php diff --git a/src/Handler/FlowJSUploadHandler.php b/src/Handler/FlowJSUploadHandler.php new file mode 100644 index 0000000..5b9c37b --- /dev/null +++ b/src/Handler/FlowJSUploadHandler.php @@ -0,0 +1,85 @@ +fileUuid = $request->get(self::CHUNK_UUID_INDEX); + } + + /** + * Append the resumable file - uuid and pass the current chunk index for parallel upload. + * + * @return string + */ + public function getChunkFileName() + { + return $this->createChunkFileName($this->fileUuid, $this->getCurrentChunk()); + } + + /** + * Returns current chunk from the request. + * + * @param Request $request + * + * @return int + */ + protected function getCurrentChunkFromRequest(Request $request) + { + return $request->get(self::CHUNK_NUMBER_INDEX); + } + + /** + * Returns current chunk from the request. + * + * @param Request $request + * + * @return int + */ + protected function getTotalChunksFromRequest(Request $request) + { + return $request->get(self::TOTAL_CHUNKS_INDEX); + } + + /** + * Checks if the current abstract handler can be used via HandlerFactory. + * + * @param Request $request + * + * @return bool + */ + public static function canBeUsedForRequest(Request $request) + { + return $request->has(self::CHUNK_NUMBER_INDEX) && $request->has(self::TOTAL_CHUNKS_INDEX) && + $request->has(self::CHUNK_UUID_INDEX); + } +} From 98ac728135a45cd5764911d071be3c008b2a9a7b Mon Sep 17 00:00:00 2001 From: jackburr Date: Mon, 1 Feb 2021 22:09:25 +0100 Subject: [PATCH 2/2] Update HandlerFactory.php --- src/Handler/HandlerFactory.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Handler/HandlerFactory.php b/src/Handler/HandlerFactory.php index 832cbd6..bbc9475 100644 --- a/src/Handler/HandlerFactory.php +++ b/src/Handler/HandlerFactory.php @@ -14,6 +14,7 @@ class HandlerFactory protected static $handlers = [ ContentRangeUploadHandler::class, ChunksInRequestUploadHandler::class, + FlowJSUploadHandler::class, ResumableJSUploadHandler::class, DropZoneUploadHandler::class, ChunksInRequestSimpleUploadHandler::class,