Commit ae8de68c authored by Ehsan Fakhraie's avatar Ehsan Fakhraie

Two Methods for Video Upload Generated

1:tus
2:normal
parent 1d0662f2
/node_modules/
...@@ -2,141 +2,35 @@ ...@@ -2,141 +2,35 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="775582b5-a7ad-4195-9e5c-b03955643ffa" name="Default Changelist" comment=""> <list default="true" id="775582b5-a7ad-4195-9e5c-b03955643ffa" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/api/smsVerification.php" afterDir="false" /> <change afterPath="$PROJECT_DIR$/demos/browser/demo.css" afterDir="false" />
<change afterPath="$PROJECT_DIR$/components/functions.php" afterDir="false" /> <change afterPath="$PROJECT_DIR$/demos/browser/demo.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/autoload.php" afterDir="false" /> <change afterPath="$PROJECT_DIR$/demos/browser/index.html" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/composer/ClassLoader.php" afterDir="false" /> <change afterPath="$PROJECT_DIR$/dist/tus.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/composer/LICENSE" afterDir="false" /> <change afterPath="$PROJECT_DIR$/dist/tus.js.map" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/composer/autoload_classmap.php" afterDir="false" /> <change afterPath="$PROJECT_DIR$/dist/tus.min.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/composer/autoload_files.php" afterDir="false" /> <change afterPath="$PROJECT_DIR$/dist/tus.min.js.map" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/composer/autoload_namespaces.php" afterDir="false" /> <change afterPath="$PROJECT_DIR$/jqueryUpload/index.html" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/composer/autoload_psr4.php" afterDir="false" /> <change afterPath="$PROJECT_DIR$/jqueryUpload/jquery-3.4.1.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/composer/autoload_real.php" afterDir="false" /> <change afterPath="$PROJECT_DIR$/jqueryUpload/upload.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/composer/autoload_static.php" afterDir="false" /> <change afterPath="$PROJECT_DIR$/jqueryUpload/uploads/10000000_473669256664438_7210181886877671794_n.mp4" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/composer/installed.json" afterDir="false" /> <change afterPath="$PROJECT_DIR$/jqueryUpload/uploads/Connection.zip" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/.php_cs" afterDir="false" /> <change afterPath="$PROJECT_DIR$/jqueryUpload/uploads/IMG_8640.JPG" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/CHANGELOG.md" afterDir="false" /> <change afterPath="$PROJECT_DIR$/jqueryUpload/uploads/final_3_1.mp4" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/Dockerfile" afterDir="false" /> <change afterPath="$PROJECT_DIR$/jqueryUpload/uploads/uploads.txt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/LICENSE" afterDir="false" /> <change afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/README.md" afterDir="false" /> <change afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/UPGRADING.md" afterDir="false" /> <change afterPath="$PROJECT_DIR$/s.html" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/composer.json" afterDir="false" /> <change afterPath="$PROJECT_DIR$/videoTest/dropzone.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Client.php" afterDir="false" /> <change afterPath="$PROJECT_DIR$/videoTest/index.html" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/ClientInterface.php" afterDir="false" /> <change afterPath="$PROJECT_DIR$/videoTest/jquery-3.4.1.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php" afterDir="false" /> <change afterPath="$PROJECT_DIR$/videoTest/jquery.form.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php" afterDir="false" /> <change afterPath="$PROJECT_DIR$/videoTest/upload.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php" afterDir="false" /> <change afterPath="$PROJECT_DIR$/videoTest/uploads/Connection.zip" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php" afterDir="false" /> <change afterPath="$PROJECT_DIR$/videoTest/uploads/IMG_8639.JPG" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php" afterDir="false" /> <change afterPath="$PROJECT_DIR$/videoTest/uploads/IMG_8640.JPG" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php" afterDir="false" /> <change afterPath="$PROJECT_DIR$/videoTest/uploads/final_3_1.mp4" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Exception/ClientException.php" afterDir="false" /> <change afterPath="$PROJECT_DIR$/videoTest/uploads/uploads.txt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Exception/ConnectException.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Exception/GuzzleException.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Exception/InvalidArgumentException.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Exception/SeekException.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Exception/TooManyRedirectsException.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Exception/TransferException.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/HandlerStack.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/MessageFormatter.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Middleware.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/Pool.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/RequestOptions.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/TransferStats.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/UriTemplate.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/functions.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/guzzle/src/functions_include.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/promises/CHANGELOG.md" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/promises/LICENSE" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/promises/Makefile" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/promises/README.md" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/promises/composer.json" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/promises/src/AggregateException.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/promises/src/CancellationException.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/promises/src/Coroutine.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/promises/src/EachPromise.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/promises/src/FulfilledPromise.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/promises/src/Promise.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/promises/src/PromiseInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/promises/src/PromisorInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/promises/src/RejectedPromise.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/promises/src/RejectionException.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/promises/src/TaskQueue.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/promises/src/TaskQueueInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/promises/src/functions.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/promises/src/functions_include.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/CHANGELOG.md" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/LICENSE" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/README.md" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/composer.json" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/AppendStream.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/BufferStream.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/CachingStream.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/DroppingStream.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/FnStream.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/InflateStream.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/LazyOpenStream.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/LimitStream.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/MessageTrait.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/MultipartStream.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/NoSeekStream.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/PumpStream.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/Request.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/Response.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/Rfc7230.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/ServerRequest.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/Stream.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/StreamWrapper.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/UploadedFile.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/Uri.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/UriNormalizer.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/UriResolver.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/functions.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/guzzlehttp/psr7/src/functions_include.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/psr/http-message/CHANGELOG.md" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/psr/http-message/LICENSE" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/psr/http-message/README.md" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/psr/http-message/composer.json" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/psr/http-message/src/MessageInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/psr/http-message/src/RequestInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/psr/http-message/src/ResponseInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/psr/http-message/src/ServerRequestInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/psr/http-message/src/StreamInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/psr/http-message/src/UploadedFileInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/psr/http-message/src/UriInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/ralouphie/getallheaders/LICENSE" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/ralouphie/getallheaders/README.md" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/ralouphie/getallheaders/composer.json" afterDir="false" />
<change afterPath="$PROJECT_DIR$/libs/vendor/ralouphie/getallheaders/src/getallheaders.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pages/Information.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pages/login.html" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pages/login.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pages/register.html" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pages/register.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pages/script/ChangeNumbers.min.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pages/style.css" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pages/upload_section.html" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pages/verify.html" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pages/verify.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pages/welcome_page.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/sqldialects.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/sqldialects.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/database/data.json" beforeDir="false" afterPath="$PROJECT_DIR$/components/database/data.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/database/db.php" beforeDir="false" afterPath="$PROJECT_DIR$/components/database/db.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/smsPanel.php" beforeDir="false" afterPath="$PROJECT_DIR$/components/smsPanel.php" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
...@@ -166,7 +60,10 @@ ...@@ -166,7 +60,10 @@
<component name="FileTemplateManagerImpl"> <component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES"> <option name="RECENT_TEMPLATES">
<list> <list>
<option value="package.json" />
<option value="JavaScript File" />
<option value="CSS File" /> <option value="CSS File" />
<option value="HTML File" />
</list> </list>
</option> </option>
</component> </component>
...@@ -202,22 +99,27 @@ ...@@ -202,22 +99,27 @@
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="ASKED_ADD_EXTERNAL_FILES" value="true" /> <property name="ASKED_ADD_EXTERNAL_FILES" value="true" />
<property name="DatabaseDriversLRU" value="mysql" /> <property name="DatabaseDriversLRU" value="mysql" />
<property name="DefaultHtmlFileTemplate" value="HTML File" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" /> <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" /> <property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" /> <property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/pages/script" /> <property name="last_opened_file_path" value="$PROJECT_DIR$/jqueryUpload" />
<property name="list.type.of.created.stylesheet" value="CSS" /> <property name="list.type.of.created.stylesheet" value="CSS" />
<property name="nodejs_package_manager_path" value="npm" />
</component> </component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="G:\xampp2\htdocs\profile-manager\pages\script" />
<recent name="G:\xampp2\htdocs\profile-manager\pages" />
<recent name="G:\xampp2\htdocs\profile-manager" />
</key>
<key name="MoveFile.RECENT_KEYS"> <key name="MoveFile.RECENT_KEYS">
<recent name="G:\xampp2\htdocs\profile-manager\videoTest" />
<recent name="G:\xampp2\htdocs\profile-manager\Components" /> <recent name="G:\xampp2\htdocs\profile-manager\Components" />
<recent name="G:\xampp2\htdocs\profile-manager\database" /> <recent name="G:\xampp2\htdocs\profile-manager\database" />
</key> </key>
<key name="CopyFile.RECENT_KEYS">
<recent name="G:\xampp2\htdocs\profile-manager\jqueryUpload" />
<recent name="G:\xampp2\htdocs\profile-manager\videoTest" />
<recent name="G:\xampp2\htdocs\profile-manager\dist" />
<recent name="G:\xampp2\htdocs\profile-manager" />
<recent name="G:\xampp2\htdocs\profile-manager\pages\script" />
</key>
</component> </component>
<component name="ServiceViewManager"> <component name="ServiceViewManager">
<option name="viewStates"> <option name="viewStates">
...@@ -243,7 +145,8 @@ ...@@ -243,7 +145,8 @@
<updated>1579253465503</updated> <updated>1579253465503</updated>
<workItem from="1579253466623" duration="12836000" /> <workItem from="1579253466623" duration="12836000" />
<workItem from="1579269058943" duration="4581000" /> <workItem from="1579269058943" duration="4581000" />
<workItem from="1579358190270" duration="12820000" /> <workItem from="1579358190270" duration="13465000" />
<workItem from="1579416809553" duration="13360000" />
</task> </task>
<task id="LOCAL-00001" summary="Database Created,&#10;Sms Panel Added"> <task id="LOCAL-00001" summary="Database Created,&#10;Sms Panel Added">
<created>1579273628530</created> <created>1579273628530</created>
...@@ -252,7 +155,14 @@ ...@@ -252,7 +155,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1579273628530</updated> <updated>1579273628530</updated>
</task> </task>
<option name="localTasksCounter" value="2" /> <task id="LOCAL-00002" summary="Sms Panel Completed&#10;Pages and front added">
<created>1579371742566</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1579371742566</updated>
</task>
<option name="localTasksCounter" value="3" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
...@@ -261,7 +171,8 @@ ...@@ -261,7 +171,8 @@
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" /> <option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<MESSAGE value="Database Created,&#10;Sms Panel Added" /> <MESSAGE value="Database Created,&#10;Sms Panel Added" />
<option name="LAST_COMMIT_MESSAGE" value="Database Created,&#10;Sms Panel Added" /> <MESSAGE value="Sms Panel Completed&#10;Pages and front added" />
<option name="LAST_COMMIT_MESSAGE" value="Sms Panel Completed&#10;Pages and front added" />
</component> </component>
<component name="WindowStateProjectService"> <component name="WindowStateProjectService">
<state x="552" y="179" key="#SQL_Dialects" timestamp="1579259504374"> <state x="552" y="179" key="#SQL_Dialects" timestamp="1579259504374">
...@@ -272,26 +183,30 @@ ...@@ -272,26 +183,30 @@
<screen x="0" y="0" width="1920" height="1040" /> <screen x="0" y="0" width="1920" height="1040" />
</state> </state>
<state x="552" y="179" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1579259246781" /> <state x="552" y="179" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1579259246781" />
<state x="585" y="115" key="CommitChangelistDialog2" timestamp="1579273627240"> <state x="690" y="267" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1579424158849">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="690" y="267" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1579424158849" />
<state x="585" y="115" key="CommitChangelistDialog2" timestamp="1579431487831">
<screen x="0" y="0" width="1920" height="1040" /> <screen x="0" y="0" width="1920" height="1040" />
</state> </state>
<state x="585" y="115" key="CommitChangelistDialog2/0.0.1920.1040@0.0.1920.1040" timestamp="1579273627240" /> <state x="585" y="115" key="CommitChangelistDialog2/0.0.1920.1040@0.0.1920.1040" timestamp="1579431487831" />
<state x="184" y="92" key="DiffContextDialog" timestamp="1579273377744"> <state x="184" y="92" key="DiffContextDialog" timestamp="1579273377744">
<screen x="0" y="0" width="1920" height="1040" /> <screen x="0" y="0" width="1920" height="1040" />
</state> </state>
<state x="184" y="92" key="DiffContextDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1579273377744" /> <state x="184" y="92" key="DiffContextDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1579273377744" />
<state x="795" y="444" key="NewPhpFileDialog" timestamp="1579367021667"> <state x="795" y="444" key="NewPhpFileDialog" timestamp="1579424284382">
<screen x="0" y="0" width="1920" height="1040" /> <screen x="0" y="0" width="1920" height="1040" />
</state> </state>
<state x="795" y="444" key="NewPhpFileDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1579367021667" /> <state x="795" y="444" key="NewPhpFileDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1579424284382" />
<state x="552" y="253" key="Vcs.Push.Dialog.v2" timestamp="1579273634065"> <state x="552" y="253" key="Vcs.Push.Dialog.v2" timestamp="1579371746594">
<screen x="0" y="0" width="1920" height="1040" /> <screen x="0" y="0" width="1920" height="1040" />
</state> </state>
<state x="552" y="253" key="Vcs.Push.Dialog.v2/0.0.1920.1040@0.0.1920.1040" timestamp="1579273634065" /> <state x="552" y="253" key="Vcs.Push.Dialog.v2/0.0.1920.1040@0.0.1920.1040" timestamp="1579371746594" />
<state x="655" y="344" key="com.intellij.ide.util.TipDialog" timestamp="1579358192722"> <state x="655" y="344" key="com.intellij.ide.util.TipDialog" timestamp="1579416900555">
<screen x="0" y="0" width="1920" height="1040" /> <screen x="0" y="0" width="1920" height="1040" />
</state> </state>
<state x="655" y="344" key="com.intellij.ide.util.TipDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1579358192722" /> <state x="655" y="344" key="com.intellij.ide.util.TipDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1579416900555" />
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup" timestamp="1579370071419"> <state x="623" y="225" width="672" height="678" key="search.everywhere.popup" timestamp="1579370071419">
<screen x="0" y="0" width="1920" height="1040" /> <screen x="0" y="0" width="1920" height="1040" />
</state> </state>
......
body {
padding-top: 40px;
}
.progress {
height: 32px;
}
a.btn {
margin-bottom: 2px;
}
/* global tus */
/* eslint no-console: 0 */
"use strict";
var upload = null;
var uploadIsRunning = false;
var toggleBtn = document.querySelector("#toggle-btn");
var resumeCheckbox = document.querySelector("#resume");
var input = document.querySelector("input[type=file]");
var progress = document.querySelector(".progress");
var progressBar = progress.querySelector(".bar");
var alertBox = document.querySelector("#support-alert");
var uploadList = document.querySelector("#upload-list");
var chunkInput = document.querySelector("#chunksize");
var endpointInput = document.querySelector("#endpoint");
var channelId = "9708bdf6-a4a1-4807-a212-f6c994d7d975";
var authorization = "Apikey a8c3c9f1-4313-43ef-a4b0-fbd343b21302";
if (!tus.isSupported) {
alertBox.classList.remove("hidden");
}
if (!toggleBtn) {
throw new Error("Toggle button not found on this page. Aborting upload-demo. ");
}
toggleBtn.addEventListener("click", function (e) {
e.preventDefault();
if (upload) {
if (uploadIsRunning) {
upload.abort();
toggleBtn.textContent = "resume upload";
uploadIsRunning = false;
} else {
upload.start();
toggleBtn.textContent = "pause upload";
uploadIsRunning = true;
}
} else {
if (input.files.length > 0) {
startUpload();
} else {
input.click();
}
}
});
input.addEventListener("change", startUpload);
function startUpload() {
var file = input.files[0];
// Only continue if a file has actually been selected.
// IE will trigger a change event even if we reset the input element
// using reset() and we do not want to blow up later.
if (!file) {
return;
}
var endpoint = endpointInput.value;
var chunkSize = parseInt(chunkInput.value, 10);
if (isNaN(chunkSize)) {
chunkSize = Infinity;
}
toggleBtn.textContent = "pause upload";
let optionss = {
"url": `https://napi.arvancloud.com/vod/2.0/channels/${channelId}/files`,
"authorization": `${authorization}`,
"acceptLanguage": "en",
"uuid": file.name + file.size + file.lastModified
};
var options = {
resume: true,
chunkSize: chunkSize,
endpoint: optionss.url,
retryDelays: [0, 500, 1000, 1500, 2000, 2500],
headers: {
'Authorization': optionss.authorization,
'Accept-Language': optionss.acceptLanguage
},
uploadDataDuringCreation: true,
metadata: {
filename: file.name,
filetype: file.type
},
onError : function (error) {
if (error.originalRequest) {
if (window.confirm("Failed because: " + error + "\nDo you want to retry?")) {
upload.start();
uploadIsRunning = true;
return;
}
} else {
window.alert("Failed because: " + error);
}
reset();
},
onProgress: function (bytesUploaded, bytesTotal) {
var percentage = (bytesUploaded / bytesTotal * 100).toFixed(2);
progressBar.style.width = percentage + "%";
console.log(bytesUploaded, bytesTotal, percentage + "%");
},
onSuccess: function () {
var anchor = document.createElement("a");
anchor.textContent = "Download " + upload.file.name + " (" + upload.file.size + " bytes)";
anchor.href = upload.url;
anchor.className = "btn btn-success";
uploadList.appendChild(anchor);
reset();
}
};
upload = new tus.Upload(file, options);
upload.start();
uploadIsRunning = true;
}
function reset() {
input.value = "";
toggleBtn.textContent = "start upload";
upload = null;
uploadIsRunning = false;
}
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>tus-js-client demo - File Upload</title>
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet" />
<link href="./demo.css" rel="stylesheet" media="screen" />
</head>
<body>
<div class="container">
<h1>tus-js-client demo - File Upload</h1>
<p>
This demo shows the basic functionality of the tus protocol. You can select a file using the controls below and start/pause the upload as you wish.
</p>
<p>
For a prettier demo please go to the
<a href="http://tus.io/demo.html">tus.io</a> website.
This demo is just here to aid developers.
</p>
<p>
A demo where a video is recorded from your webcam while being simultaneously uploaded, can be found <a href="./video.html">here</a>.
</p>
<div class="alert alert-warining hidden" id="support-alert">
<b>Warning!</b> Your browser does not seem to support the features necessary to run tus-js-client. The buttons below may work but probably will fail silently.
</div>
<br />
<table>
<tr>
<td>
<label for="endpoint">
Upload endpoint:
</label>
</td>
<td>
<input type="text" id="endpoint" name="endpoint" value="https://master.tus.io/files/">
</td>
</tr>
<tr>
<td>
<label for="chunksize">
Chunk size (bytes):
</label>
</td>
<td>
<input type="number" id="chunksize" name="chunksize">
</td>
</tr>
<tr>
<td>
<label for="resume">
Perform full upload:
<br />
<small>(even if we could resume)</small>
</label>
</td>
<td>
<input type="checkbox" id="resume">
</td>
</tr>
</table>
<br />
<input type="file">
<br />
<br />
<div class="row">
<div class="span8">
<div class="progress progress-striped progress-success">
<div class="bar" style="width: 0%;"></div>
</div>
</div>
<div class="span4">
<button class="btn stop" id="toggle-btn">start upload</button>
</div>
</div>
<hr />
<h3>Uploads</h3>
<p id="upload-list">
Succesful uploads will be listed here. Try one!
</p>
</div>
</body>
<script src="../../dist/tus.js"></script>
<script src="./demo.js"></script>
</html>
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.tus = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = fingerprint;
var _isReactNative = _dereq_("./isReactNative");
var _isReactNative2 = _interopRequireDefault(_isReactNative);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Generate a fingerprint for a file which will be used the store the endpoint
*
* @param {File} file
* @param {Object} options
* @param {Function} callback
*/
function fingerprint(file, options, callback) {
if ((0, _isReactNative2.default)()) {
return callback(null, reactNativeFingerprint(file, options));
}
return callback(null, ["tus-br", file.name, file.type, file.size, file.lastModified, options.endpoint].join("-"));
}
function reactNativeFingerprint(file, options) {
var exifHash = file.exif ? hashCode(JSON.stringify(file.exif)) : "noexif";
return ["tus-rn", file.name || "noname", file.size || "nosize", exifHash, options.endpoint].join("/");
}
function hashCode(str) {
// from https://stackoverflow.com/a/8831937/151666
var hash = 0;
if (str.length === 0) {
return hash;
}
for (var i = 0; i < str.length; i++) {
var char = str.charCodeAt(i);
hash = (hash << 5) - hash + char;
hash = hash & hash; // Convert to 32bit integer
}
return hash;
}
},{"./isReactNative":3}],2:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var isCordova = function isCordova() {
return typeof window != "undefined" && (typeof window.PhoneGap != "undefined" || typeof window.Cordova != "undefined" || typeof window.cordova != "undefined");
};
exports.default = isCordova;
},{}],3:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var isReactNative = function isReactNative() {
return typeof navigator !== "undefined" && typeof navigator.product === "string" && navigator.product.toLowerCase() === "reactnative";
};
exports.default = isReactNative;
},{}],4:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* readAsByteArray converts a File object to a Uint8Array.
* This function is only used on the Apache Cordova platform.
* See https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/index.html#read-a-file
*/
function readAsByteArray(chunk, callback) {
var reader = new FileReader();
reader.onload = function () {
callback(null, new Uint8Array(reader.result));
};
reader.onerror = function (err) {
callback(err);
};
reader.readAsArrayBuffer(chunk);
}
exports.default = readAsByteArray;
},{}],5:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.newRequest = newRequest;
exports.resolveUrl = resolveUrl;
var _urlParse = _dereq_("url-parse");
var _urlParse2 = _interopRequireDefault(_urlParse);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function newRequest() {
return new window.XMLHttpRequest();
} /* global window */
function resolveUrl(origin, link) {
return new _urlParse2.default(link, origin).toString();
}
},{"url-parse":16}],6:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
exports.getSource = getSource;
var _isReactNative = _dereq_("./isReactNative");
var _isReactNative2 = _interopRequireDefault(_isReactNative);
var _uriToBlob = _dereq_("./uriToBlob");
var _uriToBlob2 = _interopRequireDefault(_uriToBlob);
var _isCordova = _dereq_("./isCordova");
var _isCordova2 = _interopRequireDefault(_isCordova);
var _readAsByteArray = _dereq_("./readAsByteArray");
var _readAsByteArray2 = _interopRequireDefault(_readAsByteArray);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var FileSource = function () {
function FileSource(file) {
_classCallCheck(this, FileSource);
this._file = file;
this.size = file.size;
}
_createClass(FileSource, [{
key: "slice",
value: function slice(start, end, callback) {
// In Apache Cordova applications, a File must be resolved using
// FileReader instances, see
// https://cordova.apache.org/docs/en/8.x/reference/cordova-plugin-file/index.html#read-a-file
if ((0, _isCordova2.default)()) {
(0, _readAsByteArray2.default)(this._file.slice(start, end), function (err, chunk) {
if (err) return callback(err);
callback(null, chunk);
});
return;
}
callback(null, this._file.slice(start, end));
}
}, {
key: "close",
value: function close() {}
}]);
return FileSource;
}();
var StreamSource = function () {
function StreamSource(reader, chunkSize) {
_classCallCheck(this, StreamSource);
this._chunkSize = chunkSize;
this._buffer = undefined;
this._bufferOffset = 0;
this._reader = reader;
this._done = false;
}
_createClass(StreamSource, [{
key: "slice",
value: function slice(start, end, callback) {
if (start < this._bufferOffset) {
callback(new Error("Requested data is before the reader's current offset"));
return;
}
return this._readUntilEnoughDataOrDone(start, end, callback);
}
}, {
key: "_readUntilEnoughDataOrDone",
value: function _readUntilEnoughDataOrDone(start, end, callback) {
var _this = this;
var hasEnoughData = end <= this._bufferOffset + len(this._buffer);
if (this._done || hasEnoughData) {
var value = this._getDataFromBuffer(start, end);
callback(null, value, value == null ? this._done : false);
return;
}
this._reader.read().then(function (_ref) {
var value = _ref.value,
done = _ref.done;
if (done) {
_this._done = true;
} else if (_this._buffer === undefined) {
_this._buffer = value;
} else {
_this._buffer = concat(_this._buffer, value);
}
_this._readUntilEnoughDataOrDone(start, end, callback);
}).catch(function (err) {
callback(new Error("Error during read: " + err));
});
}
}, {
key: "_getDataFromBuffer",
value: function _getDataFromBuffer(start, end) {
// Remove data from buffer before `start`.
// Data might be reread from the buffer if an upload fails, so we can only
// safely delete data when it comes *before* what is currently being read.
if (start > this._bufferOffset) {
this._buffer = this._buffer.slice(start - this._bufferOffset);
this._bufferOffset = start;
}
// If the buffer is empty after removing old data, all data has been read.
var hasAllDataBeenRead = len(this._buffer) === 0;
if (this._done && hasAllDataBeenRead) {
return null;
}
// We already removed data before `start`, so we just return the first
// chunk from the buffer.
return this._buffer.slice(0, end - start);
}
}, {
key: "close",
value: function close() {
if (this._reader.cancel) {
this._reader.cancel();
}
}
}]);
return StreamSource;
}();
function len(blobOrArray) {
if (blobOrArray === undefined) return 0;
if (blobOrArray.size !== undefined) return blobOrArray.size;
return blobOrArray.length;
}
/*
Typed arrays and blobs don't have a concat method.
This function helps StreamSource accumulate data to reach chunkSize.
*/
function concat(a, b) {
if (a.concat) {
// Is `a` an Array?
return a.concat(b);
}
if (a instanceof Blob) {
return new Blob([a, b], { type: a.type });
}
if (a.set) {
// Is `a` a typed array?
var c = new a.constructor(a.length + b.length);
c.set(a);
c.set(b, a.length);
return c;
}
throw new Error("Unknown data type");
}
function getSource(input, chunkSize, callback) {
// In React Native, when user selects a file, instead of a File or Blob,
// you usually get a file object {} with a uri property that contains
// a local path to the file. We use XMLHttpRequest to fetch
// the file blob, before uploading with tus.
if ((0, _isReactNative2.default)() && input && typeof input.uri !== "undefined") {
(0, _uriToBlob2.default)(input.uri, function (err, blob) {
if (err) {
return callback(new Error("tus: cannot fetch `file.uri` as Blob, make sure the uri is correct and accessible. " + err));
}
callback(null, new FileSource(blob));
});
return;
}
// Since we emulate the Blob type in our tests (not all target browsers
// support it), we cannot use `instanceof` for testing whether the input value
// can be handled. Instead, we simply check is the slice() function and the
// size property are available.
if (typeof input.slice === "function" && typeof input.size !== "undefined") {
callback(null, new FileSource(input));
return;
}
if (typeof input.read === "function") {
chunkSize = +chunkSize;
if (!isFinite(chunkSize)) {
callback(new Error("cannot create source for stream without a finite value for the `chunkSize` option"));
return;
}
callback(null, new StreamSource(input, chunkSize));
return;
}
callback(new Error("source object may only be an instance of File, Blob, or Reader in this environment"));
}
},{"./isCordova":2,"./isReactNative":3,"./readAsByteArray":4,"./uriToBlob":8}],7:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
exports.getStorage = getStorage;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/* global window, localStorage */
var hasStorage = false;
try {
hasStorage = "localStorage" in window;
// Attempt to store and read entries from the local storage to detect Private
// Mode on Safari on iOS (see #49)
var key = "tusSupport";
localStorage.setItem(key, localStorage.getItem(key));
} catch (e) {
// If we try to access localStorage inside a sandboxed iframe, a SecurityError
// is thrown. When in private mode on iOS Safari, a QuotaExceededError is
// thrown (see #49)
if (e.code === e.SECURITY_ERR || e.code === e.QUOTA_EXCEEDED_ERR) {
hasStorage = false;
} else {
throw e;
}
}
var canStoreURLs = exports.canStoreURLs = hasStorage;
var LocalStorage = function () {
function LocalStorage() {
_classCallCheck(this, LocalStorage);
}
_createClass(LocalStorage, [{
key: "setItem",
value: function setItem(key, value, cb) {
cb(null, localStorage.setItem(key, value));
}
}, {
key: "getItem",
value: function getItem(key, cb) {
cb(null, localStorage.getItem(key));
}
}, {
key: "removeItem",
value: function removeItem(key, cb) {
cb(null, localStorage.removeItem(key));
}
}]);
return LocalStorage;
}();
function getStorage() {
return hasStorage ? new LocalStorage() : null;
}
},{}],8:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* uriToBlob resolves a URI to a Blob object. This is used for
* React Native to retrieve a file (identified by a file://
* URI) as a blob.
*/
function uriToBlob(uri, done) {
var xhr = new XMLHttpRequest();
xhr.responseType = "blob";
xhr.onload = function () {
var blob = xhr.response;
done(null, blob);
};
xhr.onerror = function (err) {
done(err);
};
xhr.open("GET", uri);
xhr.send();
}
exports.default = uriToBlob;
},{}],9:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var DetailedError = function (_Error) {
_inherits(DetailedError, _Error);
function DetailedError(error) {
var causingErr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var xhr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
_classCallCheck(this, DetailedError);
var _this = _possibleConstructorReturn(this, (DetailedError.__proto__ || Object.getPrototypeOf(DetailedError)).call(this, error.message));
_this.originalRequest = xhr;
_this.causingError = causingErr;
var message = error.message;
if (causingErr != null) {
message += ", caused by " + causingErr.toString();
}
if (xhr != null) {
message += ", originated from request (response code: " + xhr.status + ", response text: " + xhr.responseText + ")";
}
_this.message = message;
return _this;
}
return DetailedError;
}(Error);
exports.default = DetailedError;
},{}],10:[function(_dereq_,module,exports){
"use strict";
var _upload = _dereq_("./upload");
var _upload2 = _interopRequireDefault(_upload);
var _storage = _dereq_("./node/storage");
var storage = _interopRequireWildcard(_storage);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* global window */
var defaultOptions = _upload2.default.defaultOptions;
var moduleExport = {
Upload: _upload2.default,
canStoreURLs: storage.canStoreURLs,
defaultOptions: defaultOptions
};
if (typeof window !== "undefined") {
// Browser environment using XMLHttpRequest
var _window = window,
XMLHttpRequest = _window.XMLHttpRequest,
Blob = _window.Blob;
moduleExport.isSupported = XMLHttpRequest && Blob && typeof Blob.prototype.slice === "function";
} else {
// Node.js environment using http module
moduleExport.isSupported = true;
// make FileStorage module available as it will not be set by default.
moduleExport.FileStorage = storage.FileStorage;
}
// The usage of the commonjs exporting syntax instead of the new ECMAScript
// one is actually inteded and prevents weird behaviour if we are trying to
// import this module in another module using Babel.
module.exports = moduleExport;
},{"./node/storage":7,"./upload":11}],11:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* global window */
// We import the files used inside the Node environment which are rewritten
// for browsers using the rules defined in the package.json
var _error = _dereq_("./error");
var _error2 = _interopRequireDefault(_error);
var _extend = _dereq_("extend");
var _extend2 = _interopRequireDefault(_extend);
var _jsBase = _dereq_("js-base64");
var _request = _dereq_("./node/request");
var _source = _dereq_("./node/source");
var _storage = _dereq_("./node/storage");
var _fingerprint = _dereq_("./node/fingerprint");
var _fingerprint2 = _interopRequireDefault(_fingerprint);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var defaultOptions = {
endpoint: null,
fingerprint: _fingerprint2.default,
resume: true,
onProgress: null,
onChunkComplete: null,
onSuccess: null,
onError: null,
headers: {},
chunkSize: Infinity,
withCredentials: false,
uploadUrl: null,
uploadSize: null,
overridePatchMethod: false,
retryDelays: null,
removeFingerprintOnSuccess: false,
uploadLengthDeferred: false,
urlStorage: null,
fileReader: null,
uploadDataDuringCreation: false
};
var Upload = function () {
function Upload(file, options) {
_classCallCheck(this, Upload);
this.options = (0, _extend2.default)(true, {}, defaultOptions, options);
// The storage module used to store URLs
this._storage = this.options.urlStorage;
// The underlying File/Blob object
this.file = file;
// The URL against which the file will be uploaded
this.url = null;
// The underlying XHR object for the current PATCH request
this._xhr = null;
// The fingerpinrt for the current file (set after start())
this._fingerprint = null;
// The offset used in the current PATCH request
this._offset = null;
// True if the current PATCH request has been aborted
this._aborted = false;
// The file's size in bytes
this._size = null;
// The Source object which will wrap around the given file and provides us
// with a unified interface for getting its size and slice chunks from its
// content allowing us to easily handle Files, Blobs, Buffers and Streams.
this._source = null;
// The current count of attempts which have been made. Null indicates none.
this._retryAttempt = 0;
// The timeout's ID which is used to delay the next retry
this._retryTimeout = null;
// The offset of the remote upload before the latest attempt was started.
this._offsetBeforeRetry = 0;
}
_createClass(Upload, [{
key: "start",
value: function start() {
var _this = this;
var file = this.file;
if (!file) {
this._emitError(new Error("tus: no file or stream to upload provided"));
return;
}
if (!this.options.endpoint && !this.options.uploadUrl) {
this._emitError(new Error("tus: neither an endpoint or an upload URL is provided"));
return;
}
if (this.options.resume && this._storage == null) {
this._storage = (0, _storage.getStorage)();
}
if (this._source) {
this._start(this._source);
} else {
var fileReader = this.options.fileReader || _source.getSource;
fileReader(file, this.options.chunkSize, function (err, source) {
if (err) {
_this._emitError(err);
return;
}
_this._source = source;
_this._start(source);
});
}
}
}, {
key: "_start",
value: function _start(source) {
var _this2 = this;
var file = this.file;
// First, we look at the uploadLengthDeferred option.
// Next, we check if the caller has supplied a manual upload size.
// Finally, we try to use the calculated size from the source object.
if (this.options.uploadLengthDeferred) {
this._size = null;
} else if (this.options.uploadSize != null) {
this._size = +this.options.uploadSize;
if (isNaN(this._size)) {
this._emitError(new Error("tus: cannot convert `uploadSize` option into a number"));
return;
}
} else {
this._size = source.size;
if (this._size == null) {
this._emitError(new Error("tus: cannot automatically derive upload's size from input and must be specified manually using the `uploadSize` option"));
return;
}
}
var retryDelays = this.options.retryDelays;
if (retryDelays != null) {
if (Object.prototype.toString.call(retryDelays) !== "[object Array]") {
this._emitError(new Error("tus: the `retryDelays` option must either be an array or null"));
return;
} else {
var errorCallback = this.options.onError;
this.options.onError = function (err) {
// Restore the original error callback which may have been set.
_this2.options.onError = errorCallback;
// We will reset the attempt counter if
// - we were already able to connect to the server (offset != null) and
// - we were able to upload a small chunk of data to the server
var shouldResetDelays = _this2._offset != null && _this2._offset > _this2._offsetBeforeRetry;
if (shouldResetDelays) {
_this2._retryAttempt = 0;
}
var isOnline = true;
if (typeof window !== "undefined" && "navigator" in window && window.navigator.onLine === false) {
isOnline = false;
}
// We only attempt a retry if
// - we didn't exceed the maxium number of retries, yet, and
// - this error was caused by a request or it's response and
// - the error is server error (i.e. no a status 4xx or a 409 or 423) and
// - the browser does not indicate that we are offline
var status = err.originalRequest ? err.originalRequest.status : 0;
var isServerError = !inStatusCategory(status, 400) || status === 409 || status === 423;
var shouldRetry = _this2._retryAttempt < retryDelays.length && err.originalRequest != null && isServerError && isOnline;
if (!shouldRetry) {
_this2._emitError(err);
return;
}
var delay = retryDelays[_this2._retryAttempt++];
_this2._offsetBeforeRetry = _this2._offset;
_this2.options.uploadUrl = _this2.url;
_this2._retryTimeout = setTimeout(function () {
_this2.start();
}, delay);
};
}
}
// Reset the aborted flag when the upload is started or else the
// _startUpload will stop before sending a request if the upload has been
// aborted previously.
this._aborted = false;
// The upload had been started previously and we should reuse this URL.
if (this.url != null) {
this._resumeUpload();
return;
}
// A URL has manually been specified, so we try to resume
if (this.options.uploadUrl != null) {
this.url = this.options.uploadUrl;
this._resumeUpload();
return;
}
// Try to find the endpoint for the file in the storage
if (this._hasStorage()) {
this.options.fingerprint(file, this.options, function (err, fingerprintValue) {
if (err) {
_this2._emitError(err);
return;
}
_this2._fingerprint = fingerprintValue;
_this2._storage.getItem(_this2._fingerprint, function (err, resumedUrl) {
if (err) {
_this2._emitError(err);
return;
}
if (resumedUrl != null) {
_this2.url = resumedUrl;
_this2._resumeUpload();
} else {
_this2._createUpload();
}
});
});
} else {
// An upload has not started for the file yet, so we start a new one
this._createUpload();
}
}
}, {
key: "abort",
value: function abort(shouldTerminate, cb) {
var _this3 = this;
if (this._xhr !== null) {
this._xhr.abort();
this._source.close();
}
this._aborted = true;
if (this._retryTimeout != null) {
clearTimeout(this._retryTimeout);
this._retryTimeout = null;
}
cb = cb || function () {};
if (shouldTerminate) {
Upload.terminate(this.url, this.options, function (err, xhr) {
if (err) {
return cb(err, xhr);
}
_this3._hasStorage() ? _this3._storage.removeItem(_this3._fingerprint, cb) : cb();
});
} else {
cb();
}
}
}, {
key: "_hasStorage",
value: function _hasStorage() {
return this.options.resume && this._storage;
}
}, {
key: "_emitXhrError",
value: function _emitXhrError(xhr, err, causingErr) {
this._emitError(new _error2.default(err, causingErr, xhr));
}
}, {
key: "_emitError",
value: function _emitError(err) {
if (typeof this.options.onError === "function") {
this.options.onError(err);
} else {
throw err;
}
}
}, {
key: "_emitSuccess",
value: function _emitSuccess() {
if (typeof this.options.onSuccess === "function") {
this.options.onSuccess();
}
}
/**
* Publishes notification when data has been sent to the server. This
* data may not have been accepted by the server yet.
* @param {number} bytesSent Number of bytes sent to the server.
* @param {number} bytesTotal Total number of bytes to be sent to the server.
*/
}, {
key: "_emitProgress",
value: function _emitProgress(bytesSent, bytesTotal) {
if (typeof this.options.onProgress === "function") {
this.options.onProgress(bytesSent, bytesTotal);
}
}
/**
* Publishes notification when a chunk of data has been sent to the server
* and accepted by the server.
* @param {number} chunkSize Size of the chunk that was accepted by the
* server.
* @param {number} bytesAccepted Total number of bytes that have been
* accepted by the server.
* @param {number} bytesTotal Total number of bytes to be sent to the server.
*/
}, {
key: "_emitChunkComplete",
value: function _emitChunkComplete(chunkSize, bytesAccepted, bytesTotal) {
if (typeof this.options.onChunkComplete === "function") {
this.options.onChunkComplete(chunkSize, bytesAccepted, bytesTotal);
}
}
/**
* Set the headers used in the request and the withCredentials property
* as defined in the options
*
* @param {XMLHttpRequest} xhr
*/
}, {
key: "_setupXHR",
value: function _setupXHR(xhr) {
this._xhr = xhr;
setupXHR(xhr, this.options);
}
/**
* Create a new upload using the creation extension by sending a POST
* request to the endpoint. After successful creation the file will be
* uploaded
*
* @api private
*/
}, {
key: "_createUpload",
value: function _createUpload() {
var _this4 = this;
if (!this.options.endpoint) {
this._emitError(new Error("tus: unable to create upload because no endpoint is provided"));
return;
}
var xhr = (0, _request.newRequest)();
xhr.open("POST", this.options.endpoint, true);
xhr.onload = function () {
if (!inStatusCategory(xhr.status, 200)) {
_this4._emitXhrError(xhr, new Error("tus: unexpected response while creating upload"));
return;
}
var location = xhr.getResponseHeader("Location");
if (location == null) {
_this4._emitXhrError(xhr, new Error("tus: invalid or missing Location header"));
return;
}
_this4.url = (0, _request.resolveUrl)(_this4.options.endpoint, location);
if (_this4._size === 0) {
// Nothing to upload and file was successfully created
_this4._emitSuccess();
_this4._source.close();
return;
}
if (_this4._hasStorage()) {
_this4._storage.setItem(_this4._fingerprint, _this4.url, function (err) {
if (err) {
_this4._emitError(err);
}
});
}
if (_this4.options.uploadDataDuringCreation) {
_this4._handleUploadResponse(xhr);
} else {
_this4._offset = 0;
_this4._startUpload();
}
};
xhr.onerror = function (err) {
_this4._emitXhrError(xhr, new Error("tus: failed to create upload"), err);
};
this._setupXHR(xhr);
if (this.options.uploadLengthDeferred) {
xhr.setRequestHeader("Upload-Defer-Length", 1);
} else {
xhr.setRequestHeader("Upload-Length", this._size);
}
// Add metadata if values have been added
var metadata = encodeMetadata(this.options.metadata);
if (metadata !== "") {
xhr.setRequestHeader("Upload-Metadata", metadata);
}
if (this.options.uploadDataDuringCreation && !this.options.uploadLengthDeferred) {
this._offset = 0;
this._addChunkToRequest(xhr);
} else {
xhr.send(null);
}
}
/*
* Try to resume an existing upload. First a HEAD request will be sent
* to retrieve the offset. If the request fails a new upload will be
* created. In the case of a successful response the file will be uploaded.
*
* @api private
*/
}, {
key: "_resumeUpload",
value: function _resumeUpload() {
var _this5 = this;
var xhr = (0, _request.newRequest)();
xhr.open("HEAD", this.url, true);
xhr.onload = function () {
if (!inStatusCategory(xhr.status, 200)) {
if (_this5._hasStorage() && inStatusCategory(xhr.status, 400)) {
// Remove stored fingerprint and corresponding endpoint,
// on client errors since the file can not be found
_this5._storage.removeItem(_this5._fingerprint, function (err) {
if (err) {
_this5._emitError(err);
}
});
}
// If the upload is locked (indicated by the 423 Locked status code), we
// emit an error instead of directly starting a new upload. This way the
// retry logic can catch the error and will retry the upload. An upload
// is usually locked for a short period of time and will be available
// afterwards.
if (xhr.status === 423) {
_this5._emitXhrError(xhr, new Error("tus: upload is currently locked; retry later"));
return;
}
if (!_this5.options.endpoint) {
// Don't attempt to create a new upload if no endpoint is provided.
_this5._emitXhrError(xhr, new Error("tus: unable to resume upload (new upload cannot be created without an endpoint)"));
return;
}
// Try to create a new upload
_this5.url = null;
_this5._createUpload();
return;
}
var offset = parseInt(xhr.getResponseHeader("Upload-Offset"), 10);
if (isNaN(offset)) {
_this5._emitXhrError(xhr, new Error("tus: invalid or missing offset value"));
return;
}
var length = parseInt(xhr.getResponseHeader("Upload-Length"), 10);
if (isNaN(length) && !_this5.options.uploadLengthDeferred) {
_this5._emitXhrError(xhr, new Error("tus: invalid or missing length value"));
return;
}
// Upload has already been completed and we do not need to send additional
// data to the server
if (offset === length) {
_this5._emitProgress(length, length);
_this5._emitSuccess();
return;
}
_this5._offset = offset;
_this5._startUpload();
};
xhr.onerror = function (err) {
_this5._emitXhrError(xhr, new Error("tus: failed to resume upload"), err);
};
this._setupXHR(xhr);
xhr.send(null);
}
/**
* Start uploading the file using PATCH requests. The file will be divided
* into chunks as specified in the chunkSize option. During the upload
* the onProgress event handler may be invoked multiple times.
*
* @api private
*/
}, {
key: "_startUpload",
value: function _startUpload() {
var _this6 = this;
// If the upload has been aborted, we will not send the next PATCH request.
// This is important if the abort method was called during a callback, such
// as onChunkComplete or onProgress.
if (this._aborted) {
return;
}
var xhr = (0, _request.newRequest)();
// Some browser and servers may not support the PATCH method. For those
// cases, you can tell tus-js-client to use a POST request with the
// X-HTTP-Method-Override header for simulating a PATCH request.
if (this.options.overridePatchMethod) {
xhr.open("POST", this.url, true);
xhr.setRequestHeader("X-HTTP-Method-Override", "PATCH");
} else {
xhr.open("PATCH", this.url, true);
}
xhr.onload = function () {
if (!inStatusCategory(xhr.status, 200)) {
_this6._emitXhrError(xhr, new Error("tus: unexpected response while uploading chunk"));
return;
}
_this6._handleUploadResponse(xhr);
};
xhr.onerror = function (err) {
// Don't emit an error if the upload was aborted manually
if (_this6._aborted) {
return;
}
_this6._emitXhrError(xhr, new Error("tus: failed to upload chunk at offset " + _this6._offset), err);
};
this._setupXHR(xhr);
xhr.setRequestHeader("Upload-Offset", this._offset);
this._addChunkToRequest(xhr);
}
/**
* _addChunktoRequest reads a chunk from the source and sends it using the
* supplied XHR object. It will not handle the response.
*/
}, {
key: "_addChunkToRequest",
value: function _addChunkToRequest(xhr) {
var _this7 = this;
// Test support for progress events before attaching an event listener
if ("upload" in xhr) {
xhr.upload.onprogress = function (e) {
if (!e.lengthComputable) {
return;
}
_this7._emitProgress(start + e.loaded, _this7._size);
};
}
xhr.setRequestHeader("Content-Type", "application/offset+octet-stream");
var start = this._offset;
var end = this._offset + this.options.chunkSize;
// The specified chunkSize may be Infinity or the calcluated end position
// may exceed the file's size. In both cases, we limit the end position to
// the input's total size for simpler calculations and correctness.
if ((end === Infinity || end > this._size) && !this.options.uploadLengthDeferred) {
end = this._size;
}
this._source.slice(start, end, function (err, value, complete) {
if (err) {
_this7._emitError(err);
return;
}
if (_this7.options.uploadLengthDeferred) {
if (complete) {
_this7._size = _this7._offset + (value && value.size ? value.size : 0);
xhr.setRequestHeader("Upload-Length", _this7._size);
}
}
if (value === null) {
xhr.send();
} else {
xhr.send(value);
_this7._emitProgress(_this7._offset, _this7._size);
}
});
}
/**
* _handleUploadResponse is used by requests that haven been sent using _addChunkToRequest
* and already have received a response.
*/
}, {
key: "_handleUploadResponse",
value: function _handleUploadResponse(xhr) {
var _this8 = this;
var offset = parseInt(xhr.getResponseHeader("Upload-Offset"), 10);
if (isNaN(offset)) {
this._emitXhrError(xhr, new Error("tus: invalid or missing offset value"));
return;
}
this._emitProgress(offset, this._size);
this._emitChunkComplete(offset - this._offset, offset, this._size);
this._offset = offset;
if (offset == this._size) {
if (this.options.removeFingerprintOnSuccess && this.options.resume) {
// Remove stored fingerprint and corresponding endpoint. This causes
// new upload of the same file must be treated as a different file.
this._storage.removeItem(this._fingerprint, function (err) {
if (err) {
_this8._emitError(err);
}
});
}
// Yay, finally done :)
this._emitSuccess();
this._source.close();
return;
}
this._startUpload();
}
}], [{
key: "terminate",
value: function terminate(url, options, cb) {
if (typeof options !== "function" && typeof cb !== "function") {
throw new Error("tus: a callback function must be specified");
}
if (typeof options === "function") {
cb = options;
options = {};
}
var xhr = (0, _request.newRequest)();
xhr.open("DELETE", url, true);
xhr.onload = function () {
if (xhr.status !== 204) {
cb(new _error2.default(new Error("tus: unexpected response while terminating upload"), null, xhr));
return;
}
cb();
};
xhr.onerror = function (err) {
cb(new _error2.default(err, new Error("tus: failed to terminate upload"), xhr));
};
setupXHR(xhr, options);
xhr.send(null);
}
}]);
return Upload;
}();
function encodeMetadata(metadata) {
var encoded = [];
for (var key in metadata) {
encoded.push(key + " " + _jsBase.Base64.encode(metadata[key]));
}
return encoded.join(",");
}
/**
* Checks whether a given status is in the range of the expected category.
* For example, only a status between 200 and 299 will satisfy the category 200.
*
* @api private
*/
function inStatusCategory(status, category) {
return status >= category && status < category + 100;
}
function setupXHR(xhr, options) {
xhr.setRequestHeader("Tus-Resumable", "1.0.0");
var headers = options.headers || {};
for (var name in headers) {
xhr.setRequestHeader(name, headers[name]);
}
xhr.withCredentials = options.withCredentials;
}
Upload.defaultOptions = defaultOptions;
exports.default = Upload;
},{"./error":9,"./node/fingerprint":1,"./node/request":5,"./node/source":6,"./node/storage":7,"extend":12,"js-base64":13}],12:[function(_dereq_,module,exports){
'use strict';
var hasOwn = Object.prototype.hasOwnProperty;
var toStr = Object.prototype.toString;
var defineProperty = Object.defineProperty;
var gOPD = Object.getOwnPropertyDescriptor;
var isArray = function isArray(arr) {
if (typeof Array.isArray === 'function') {
return Array.isArray(arr);
}
return toStr.call(arr) === '[object Array]';
};
var isPlainObject = function isPlainObject(obj) {
if (!obj || toStr.call(obj) !== '[object Object]') {
return false;
}
var hasOwnConstructor = hasOwn.call(obj, 'constructor');
var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
// Not own constructor property must be Object
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
return false;
}
// Own properties are enumerated firstly, so to speed up,
// if last one is own, then all properties are own.
var key;
for (key in obj) { /**/ }
return typeof key === 'undefined' || hasOwn.call(obj, key);
};
// If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target
var setProperty = function setProperty(target, options) {
if (defineProperty && options.name === '__proto__') {
defineProperty(target, options.name, {
enumerable: true,
configurable: true,
value: options.newValue,
writable: true
});
} else {
target[options.name] = options.newValue;
}
};
// Return undefined instead of __proto__ if '__proto__' is not an own property
var getProperty = function getProperty(obj, name) {
if (name === '__proto__') {
if (!hasOwn.call(obj, name)) {
return void 0;
} else if (gOPD) {
// In early versions of node, obj['__proto__'] is buggy when obj has
// __proto__ as an own property. Object.getOwnPropertyDescriptor() works.
return gOPD(obj, name).value;
}
}
return obj[name];
};
module.exports = function extend() {
var options, name, src, copy, copyIsArray, clone;
var target = arguments[0];
var i = 1;
var length = arguments.length;
var deep = false;
// Handle a deep copy situation
if (typeof target === 'boolean') {
deep = target;
target = arguments[1] || {};
// skip the boolean and the target
i = 2;
}
if (target == null || (typeof target !== 'object' && typeof target !== 'function')) {
target = {};
}
for (; i < length; ++i) {
options = arguments[i];
// Only deal with non-null/undefined values
if (options != null) {
// Extend the base object
for (name in options) {
src = getProperty(target, name);
copy = getProperty(options, name);
// Prevent never-ending loop
if (target !== copy) {
// Recurse if we're merging plain objects or arrays
if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
if (copyIsArray) {
copyIsArray = false;
clone = src && isArray(src) ? src : [];
} else {
clone = src && isPlainObject(src) ? src : {};
}
// Never move original objects, clone them
setProperty(target, { name: name, newValue: extend(deep, clone, copy) });
// Don't bring in undefined values
} else if (typeof copy !== 'undefined') {
setProperty(target, { name: name, newValue: copy });
}
}
}
}
}
// Return the modified object
return target;
};
},{}],13:[function(_dereq_,module,exports){
(function (global){
/*
* base64.js
*
* Licensed under the BSD 3-Clause License.
* http://opensource.org/licenses/BSD-3-Clause
*
* References:
* http://en.wikipedia.org/wiki/Base64
*/
;(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined'
? module.exports = factory(global)
: typeof define === 'function' && define.amd
? define(factory) : factory(global)
}((
typeof self !== 'undefined' ? self
: typeof window !== 'undefined' ? window
: typeof global !== 'undefined' ? global
: this
), function(global) {
'use strict';
// existing version for noConflict()
var _Base64 = global.Base64;
var version = "2.4.9";
// if node.js and NOT React Native, we use Buffer
var buffer;
if (typeof module !== 'undefined' && module.exports) {
try {
buffer = eval("require('buffer').Buffer");
} catch (err) {
buffer = undefined;
}
}
// constants
var b64chars
= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
var b64tab = function(bin) {
var t = {};
for (var i = 0, l = bin.length; i < l; i++) t[bin.charAt(i)] = i;
return t;
}(b64chars);
var fromCharCode = String.fromCharCode;
// encoder stuff
var cb_utob = function(c) {
if (c.length < 2) {
var cc = c.charCodeAt(0);
return cc < 0x80 ? c
: cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6))
+ fromCharCode(0x80 | (cc & 0x3f)))
: (fromCharCode(0xe0 | ((cc >>> 12) & 0x0f))
+ fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
+ fromCharCode(0x80 | ( cc & 0x3f)));
} else {
var cc = 0x10000
+ (c.charCodeAt(0) - 0xD800) * 0x400
+ (c.charCodeAt(1) - 0xDC00);
return (fromCharCode(0xf0 | ((cc >>> 18) & 0x07))
+ fromCharCode(0x80 | ((cc >>> 12) & 0x3f))
+ fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
+ fromCharCode(0x80 | ( cc & 0x3f)));
}
};
var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
var utob = function(u) {
return u.replace(re_utob, cb_utob);
};
var cb_encode = function(ccc) {
var padlen = [0, 2, 1][ccc.length % 3],
ord = ccc.charCodeAt(0) << 16
| ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8)
| ((ccc.length > 2 ? ccc.charCodeAt(2) : 0)),
chars = [
b64chars.charAt( ord >>> 18),
b64chars.charAt((ord >>> 12) & 63),
padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
];
return chars.join('');
};
var btoa = global.btoa ? function(b) {
return global.btoa(b);
} : function(b) {
return b.replace(/[\s\S]{1,3}/g, cb_encode);
};
var _encode = buffer ?
buffer.from && Uint8Array && buffer.from !== Uint8Array.from
? function (u) {
return (u.constructor === buffer.constructor ? u : buffer.from(u))
.toString('base64')
}
: function (u) {
return (u.constructor === buffer.constructor ? u : new buffer(u))
.toString('base64')
}
: function (u) { return btoa(utob(u)) }
;
var encode = function(u, urisafe) {
return !urisafe
? _encode(String(u))
: _encode(String(u)).replace(/[+\/]/g, function(m0) {
return m0 == '+' ? '-' : '_';
}).replace(/=/g, '');
};
var encodeURI = function(u) { return encode(u, true) };
// decoder stuff
var re_btou = new RegExp([
'[\xC0-\xDF][\x80-\xBF]',
'[\xE0-\xEF][\x80-\xBF]{2}',
'[\xF0-\xF7][\x80-\xBF]{3}'
].join('|'), 'g');
var cb_btou = function(cccc) {
switch(cccc.length) {
case 4:
var cp = ((0x07 & cccc.charCodeAt(0)) << 18)
| ((0x3f & cccc.charCodeAt(1)) << 12)
| ((0x3f & cccc.charCodeAt(2)) << 6)
| (0x3f & cccc.charCodeAt(3)),
offset = cp - 0x10000;
return (fromCharCode((offset >>> 10) + 0xD800)
+ fromCharCode((offset & 0x3FF) + 0xDC00));
case 3:
return fromCharCode(
((0x0f & cccc.charCodeAt(0)) << 12)
| ((0x3f & cccc.charCodeAt(1)) << 6)
| (0x3f & cccc.charCodeAt(2))
);
default:
return fromCharCode(
((0x1f & cccc.charCodeAt(0)) << 6)
| (0x3f & cccc.charCodeAt(1))
);
}
};
var btou = function(b) {
return b.replace(re_btou, cb_btou);
};
var cb_decode = function(cccc) {
var len = cccc.length,
padlen = len % 4,
n = (len > 0 ? b64tab[cccc.charAt(0)] << 18 : 0)
| (len > 1 ? b64tab[cccc.charAt(1)] << 12 : 0)
| (len > 2 ? b64tab[cccc.charAt(2)] << 6 : 0)
| (len > 3 ? b64tab[cccc.charAt(3)] : 0),
chars = [
fromCharCode( n >>> 16),
fromCharCode((n >>> 8) & 0xff),
fromCharCode( n & 0xff)
];
chars.length -= [0, 0, 2, 1][padlen];
return chars.join('');
};
var atob = global.atob ? function(a) {
return global.atob(a);
} : function(a){
return a.replace(/[\s\S]{1,4}/g, cb_decode);
};
var _decode = buffer ?
buffer.from && Uint8Array && buffer.from !== Uint8Array.from
? function(a) {
return (a.constructor === buffer.constructor
? a : buffer.from(a, 'base64')).toString();
}
: function(a) {
return (a.constructor === buffer.constructor
? a : new buffer(a, 'base64')).toString();
}
: function(a) { return btou(atob(a)) };
var decode = function(a){
return _decode(
String(a).replace(/[-_]/g, function(m0) { return m0 == '-' ? '+' : '/' })
.replace(/[^A-Za-z0-9\+\/]/g, '')
);
};
var noConflict = function() {
var Base64 = global.Base64;
global.Base64 = _Base64;
return Base64;
};
// export Base64
global.Base64 = {
VERSION: version,
atob: atob,
btoa: btoa,
fromBase64: decode,
toBase64: encode,
utob: utob,
encode: encode,
encodeURI: encodeURI,
btou: btou,
decode: decode,
noConflict: noConflict,
__buffer__: buffer
};
// if ES5 is available, make Base64.extendString() available
if (typeof Object.defineProperty === 'function') {
var noEnum = function(v){
return {value:v,enumerable:false,writable:true,configurable:true};
};
global.Base64.extendString = function () {
Object.defineProperty(
String.prototype, 'fromBase64', noEnum(function () {
return decode(this)
}));
Object.defineProperty(
String.prototype, 'toBase64', noEnum(function (urisafe) {
return encode(this, urisafe)
}));
Object.defineProperty(
String.prototype, 'toBase64URI', noEnum(function () {
return encode(this, true)
}));
};
}
//
// export Base64 to the namespace
//
if (global['Meteor']) { // Meteor.js
Base64 = global.Base64;
}
// module.exports and AMD are mutually exclusive.
// module.exports has precedence.
if (typeof module !== 'undefined' && module.exports) {
module.exports.Base64 = global.Base64;
}
else if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], function(){ return global.Base64 });
}
// that's it!
return {Base64: global.Base64}
}));
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],14:[function(_dereq_,module,exports){
'use strict';
var has = Object.prototype.hasOwnProperty;
/**
* Decode a URI encoded string.
*
* @param {String} input The URI encoded string.
* @returns {String} The decoded string.
* @api private
*/
function decode(input) {
return decodeURIComponent(input.replace(/\+/g, ' '));
}
/**
* Simple query string parser.
*
* @param {String} query The query string that needs to be parsed.
* @returns {Object}
* @api public
*/
function querystring(query) {
var parser = /([^=?&]+)=?([^&]*)/g
, result = {}
, part;
while (part = parser.exec(query)) {
var key = decode(part[1])
, value = decode(part[2]);
//
// Prevent overriding of existing properties. This ensures that build-in
// methods like `toString` or __proto__ are not overriden by malicious
// querystrings.
//
if (key in result) continue;
result[key] = value;
}
return result;
}
/**
* Transform a query string to an object.
*
* @param {Object} obj Object that should be transformed.
* @param {String} prefix Optional prefix.
* @returns {String}
* @api public
*/
function querystringify(obj, prefix) {
prefix = prefix || '';
var pairs = [];
//
// Optionally prefix with a '?' if needed
//
if ('string' !== typeof prefix) prefix = '?';
for (var key in obj) {
if (has.call(obj, key)) {
pairs.push(encodeURIComponent(key) +'='+ encodeURIComponent(obj[key]));
}
}
return pairs.length ? prefix + pairs.join('&') : '';
}
//
// Expose the module.
//
exports.stringify = querystringify;
exports.parse = querystring;
},{}],15:[function(_dereq_,module,exports){
'use strict';
/**
* Check if we're required to add a port number.
*
* @see https://url.spec.whatwg.org/#default-port
* @param {Number|String} port Port number we need to check
* @param {String} protocol Protocol we need to check against.
* @returns {Boolean} Is it a default port for the given protocol
* @api private
*/
module.exports = function required(port, protocol) {
protocol = protocol.split(':')[0];
port = +port;
if (!port) return false;
switch (protocol) {
case 'http':
case 'ws':
return port !== 80;
case 'https':
case 'wss':
return port !== 443;
case 'ftp':
return port !== 21;
case 'gopher':
return port !== 70;
case 'file':
return false;
}
return port !== 0;
};
},{}],16:[function(_dereq_,module,exports){
(function (global){
'use strict';
var required = _dereq_('requires-port')
, qs = _dereq_('querystringify')
, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i
, slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//;
/**
* These are the parse rules for the URL parser, it informs the parser
* about:
*
* 0. The char it Needs to parse, if it's a string it should be done using
* indexOf, RegExp using exec and NaN means set as current value.
* 1. The property we should set when parsing this value.
* 2. Indication if it's backwards or forward parsing, when set as number it's
* the value of extra chars that should be split off.
* 3. Inherit from location if non existing in the parser.
* 4. `toLowerCase` the resulting value.
*/
var rules = [
['#', 'hash'], // Extract from the back.
['?', 'query'], // Extract from the back.
function sanitize(address) { // Sanitize what is left of the address
return address.replace('\\', '/');
},
['/', 'pathname'], // Extract from the back.
['@', 'auth', 1], // Extract from the front.
[NaN, 'host', undefined, 1, 1], // Set left over value.
[/:(\d+)$/, 'port', undefined, 1], // RegExp the back.
[NaN, 'hostname', undefined, 1, 1] // Set left over.
];
/**
* These properties should not be copied or inherited from. This is only needed
* for all non blob URL's as a blob URL does not include a hash, only the
* origin.
*
* @type {Object}
* @private
*/
var ignore = { hash: 1, query: 1 };
/**
* The location object differs when your code is loaded through a normal page,
* Worker or through a worker using a blob. And with the blobble begins the
* trouble as the location object will contain the URL of the blob, not the
* location of the page where our code is loaded in. The actual origin is
* encoded in the `pathname` so we can thankfully generate a good "default"
* location from it so we can generate proper relative URL's again.
*
* @param {Object|String} loc Optional default location object.
* @returns {Object} lolcation object.
* @public
*/
function lolcation(loc) {
var location = global && global.location || {};
loc = loc || location;
var finaldestination = {}
, type = typeof loc
, key;
if ('blob:' === loc.protocol) {
finaldestination = new Url(unescape(loc.pathname), {});
} else if ('string' === type) {
finaldestination = new Url(loc, {});
for (key in ignore) delete finaldestination[key];
} else if ('object' === type) {
for (key in loc) {
if (key in ignore) continue;
finaldestination[key] = loc[key];
}
if (finaldestination.slashes === undefined) {
finaldestination.slashes = slashes.test(loc.href);
}
}
return finaldestination;
}
/**
* @typedef ProtocolExtract
* @type Object
* @property {String} protocol Protocol matched in the URL, in lowercase.
* @property {Boolean} slashes `true` if protocol is followed by "//", else `false`.
* @property {String} rest Rest of the URL that is not part of the protocol.
*/
/**
* Extract protocol information from a URL with/without double slash ("//").
*
* @param {String} address URL we want to extract from.
* @return {ProtocolExtract} Extracted information.
* @private
*/
function extractProtocol(address) {
var match = protocolre.exec(address);
return {
protocol: match[1] ? match[1].toLowerCase() : '',
slashes: !!match[2],
rest: match[3]
};
}
/**
* Resolve a relative URL pathname against a base URL pathname.
*
* @param {String} relative Pathname of the relative URL.
* @param {String} base Pathname of the base URL.
* @return {String} Resolved pathname.
* @private
*/
function resolve(relative, base) {
var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/'))
, i = path.length
, last = path[i - 1]
, unshift = false
, up = 0;
while (i--) {
if (path[i] === '.') {
path.splice(i, 1);
} else if (path[i] === '..') {
path.splice(i, 1);
up++;
} else if (up) {
if (i === 0) unshift = true;
path.splice(i, 1);
up--;
}
}
if (unshift) path.unshift('');
if (last === '.' || last === '..') path.push('');
return path.join('/');
}
/**
* The actual URL instance. Instead of returning an object we've opted-in to
* create an actual constructor as it's much more memory efficient and
* faster and it pleases my OCD.
*
* It is worth noting that we should not use `URL` as class name to prevent
* clashes with the global URL instance that got introduced in browsers.
*
* @constructor
* @param {String} address URL we want to parse.
* @param {Object|String} location Location defaults for relative paths.
* @param {Boolean|Function} parser Parser for the query string.
* @private
*/
function Url(address, location, parser) {
if (!(this instanceof Url)) {
return new Url(address, location, parser);
}
var relative, extracted, parse, instruction, index, key
, instructions = rules.slice()
, type = typeof location
, url = this
, i = 0;
//
// The following if statements allows this module two have compatibility with
// 2 different API:
//
// 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments
// where the boolean indicates that the query string should also be parsed.
//
// 2. The `URL` interface of the browser which accepts a URL, object as
// arguments. The supplied object will be used as default values / fall-back
// for relative paths.
//
if ('object' !== type && 'string' !== type) {
parser = location;
location = null;
}
if (parser && 'function' !== typeof parser) parser = qs.parse;
location = lolcation(location);
//
// Extract protocol information before running the instructions.
//
extracted = extractProtocol(address || '');
relative = !extracted.protocol && !extracted.slashes;
url.slashes = extracted.slashes || relative && location.slashes;
url.protocol = extracted.protocol || location.protocol || '';
address = extracted.rest;
//
// When the authority component is absent the URL starts with a path
// component.
//
if (!extracted.slashes) instructions[3] = [/(.*)/, 'pathname'];
for (; i < instructions.length; i++) {
instruction = instructions[i];
if (typeof instruction === 'function') {
address = instruction(address);
continue;
}
parse = instruction[0];
key = instruction[1];
if (parse !== parse) {
url[key] = address;
} else if ('string' === typeof parse) {
if (~(index = address.indexOf(parse))) {
if ('number' === typeof instruction[2]) {
url[key] = address.slice(0, index);
address = address.slice(index + instruction[2]);
} else {
url[key] = address.slice(index);
address = address.slice(0, index);
}
}
} else if ((index = parse.exec(address))) {
url[key] = index[1];
address = address.slice(0, index.index);
}
url[key] = url[key] || (
relative && instruction[3] ? location[key] || '' : ''
);
//
// Hostname, host and protocol should be lowercased so they can be used to
// create a proper `origin`.
//
if (instruction[4]) url[key] = url[key].toLowerCase();
}
//
// Also parse the supplied query string in to an object. If we're supplied
// with a custom parser as function use that instead of the default build-in
// parser.
//
if (parser) url.query = parser(url.query);
//
// If the URL is relative, resolve the pathname against the base URL.
//
if (
relative
&& location.slashes
&& url.pathname.charAt(0) !== '/'
&& (url.pathname !== '' || location.pathname !== '')
) {
url.pathname = resolve(url.pathname, location.pathname);
}
//
// We should not add port numbers if they are already the default port number
// for a given protocol. As the host also contains the port number we're going
// override it with the hostname which contains no port number.
//
if (!required(url.port, url.protocol)) {
url.host = url.hostname;
url.port = '';
}
//
// Parse down the `auth` for the username and password.
//
url.username = url.password = '';
if (url.auth) {
instruction = url.auth.split(':');
url.username = instruction[0] || '';
url.password = instruction[1] || '';
}
url.origin = url.protocol && url.host && url.protocol !== 'file:'
? url.protocol +'//'+ url.host
: 'null';
//
// The href is just the compiled result.
//
url.href = url.toString();
}
/**
* This is convenience method for changing properties in the URL instance to
* insure that they all propagate correctly.
*
* @param {String} part Property we need to adjust.
* @param {Mixed} value The newly assigned value.
* @param {Boolean|Function} fn When setting the query, it will be the function
* used to parse the query.
* When setting the protocol, double slash will be
* removed from the final url if it is true.
* @returns {URL} URL instance for chaining.
* @public
*/
function set(part, value, fn) {
var url = this;
switch (part) {
case 'query':
if ('string' === typeof value && value.length) {
value = (fn || qs.parse)(value);
}
url[part] = value;
break;
case 'port':
url[part] = value;
if (!required(value, url.protocol)) {
url.host = url.hostname;
url[part] = '';
} else if (value) {
url.host = url.hostname +':'+ value;
}
break;
case 'hostname':
url[part] = value;
if (url.port) value += ':'+ url.port;
url.host = value;
break;
case 'host':
url[part] = value;
if (/:\d+$/.test(value)) {
value = value.split(':');
url.port = value.pop();
url.hostname = value.join(':');
} else {
url.hostname = value;
url.port = '';
}
break;
case 'protocol':
url.protocol = value.toLowerCase();
url.slashes = !fn;
break;
case 'pathname':
case 'hash':
if (value) {
var char = part === 'pathname' ? '/' : '#';
url[part] = value.charAt(0) !== char ? char + value : value;
} else {
url[part] = value;
}
break;
default:
url[part] = value;
}
for (var i = 0; i < rules.length; i++) {
var ins = rules[i];
if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();
}
url.origin = url.protocol && url.host && url.protocol !== 'file:'
? url.protocol +'//'+ url.host
: 'null';
url.href = url.toString();
return url;
}
/**
* Transform the properties back in to a valid and full URL string.
*
* @param {Function} stringify Optional query stringify function.
* @returns {String} Compiled version of the URL.
* @public
*/
function toString(stringify) {
if (!stringify || 'function' !== typeof stringify) stringify = qs.stringify;
var query
, url = this
, protocol = url.protocol;
if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':';
var result = protocol + (url.slashes ? '//' : '');
if (url.username) {
result += url.username;
if (url.password) result += ':'+ url.password;
result += '@';
}
result += url.host + url.pathname;
query = 'object' === typeof url.query ? stringify(url.query) : url.query;
if (query) result += '?' !== query.charAt(0) ? '?'+ query : query;
if (url.hash) result += url.hash;
return result;
}
Url.prototype = { set: set, toString: toString };
//
// Expose the URL parser and some additional properties that might be useful for
// others or testing.
//
Url.extractProtocol = extractProtocol;
Url.location = lolcation;
Url.qs = qs;
module.exports = Url;
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"querystringify":14,"requires-port":15}]},{},[10])(10)
});
//# sourceMappingURL=tus.js.map
{
"version": 3,
"sources": [
"node_modules/browserify/node_modules/browser-pack/_prelude.js",
"lib/browser/fingerprint.js",
"lib/browser/isCordova.js",
"lib/browser/isReactNative.js",
"lib/browser/readAsByteArray.js",
"lib/browser/request.js",
"lib/browser/source.js",
"lib/browser/storage.js",
"lib/browser/uriToBlob.js",
"lib/error.js",
"lib/index.js",
"lib/upload.js",
"node_modules/extend/index.js",
"node_modules/js-base64/base64.js",
"node_modules/querystringify/index.js",
"node_modules/requires-port/index.js",
"node_modules/url-parse/index.js"
],
"names": [],
"mappings": "AAAA;;;;;;kBCSwB,W;;AATxB;;;;;;AAEA;;;;;;;AAOe,SAAS,WAAT,CAAqB,IAArB,EAA2B,OAA3B,EAAoC,QAApC,EAA8C;AAC3D,MAAI,8BAAJ,EAAqB;AACnB,WAAO,SAAS,IAAT,EAAe,uBAAuB,IAAvB,EAA6B,OAA7B,CAAf,CAAP;AACD;;AAED,SAAO,SAAS,IAAT,EAAe,CACpB,QADoB,EAEpB,KAAK,IAFe,EAGpB,KAAK,IAHe,EAIpB,KAAK,IAJe,EAKpB,KAAK,YALe,EAMpB,QAAQ,QANY,EAOpB,IAPoB,CAOf,GAPe,CAAf,CAAP;AAQD;;AAED,SAAS,sBAAT,CAAgC,IAAhC,EAAsC,OAAtC,EAA+C;AAC7C,MAAI,WAAW,KAAK,IAAL,GAAY,SAAS,KAAK,SAAL,CAAe,KAAK,IAApB,CAAT,CAAZ,GAAkD,QAAjE;AACA,SAAO,CACL,QADK,EAEL,KAAK,IAAL,IAAa,QAFR,EAGL,KAAK,IAAL,IAAa,QAHR,EAIL,QAJK,EAKL,QAAQ,QALH,EAML,IANK,CAMA,GANA,CAAP;AAOD;;AAED,SAAS,QAAT,CAAkB,GAAlB,EAAuB;AACrB;AACA,MAAI,OAAO,CAAX;AACA,MAAI,IAAI,MAAJ,KAAe,CAAnB,EAAsB;AACpB,WAAO,IAAP;AACD;AACD,OAAK,IAAI,IAAI,CAAb,EAAgB,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A,OAAK,IAAI,GAAT,IAAgB,QAAhB,EAA0B;AACxB,YAAQ,IAAR,CAAa,MAAM,GAAN,GAAY,eAAO,MAAP,CAAc,SAAS,GAAT,CAAd,CAAzB;AACD;;AAED,SAAO,QAAQ,IAAR,CAAa,GAAb,CAAP;AACD;;AAED;;;;;;AAMA,SAAS,gBAAT,CAA0B,MAA1B,EAAkC,QAAlC,EAA4C;AAC1C,SAAQ,UAAU,QAAV,IAAsB,SAAU,WAAW,GAAnD;AACD;;AAED,SAAS,QAAT,CAAkB,GAAlB,EAAuB,OAAvB,EAAgC;AAC9B,MAAI,gBAAJ,CAAqB,eAArB,EAAsC,OAAtC;AACA,MAAI,UAAU,QAAQ,OAAR,IAAmB,EAAjC;;AAEA,OAAK,IAAI,IAAT,IAAiB,OAAjB,EAA0B;AACxB,QAAI,gBAAJ,CAAqB,IAArB,EAA2B,QAAQ,IAAR,CAA3B;AACD;;AAED,MAAI,eAAJ,GAAsB,QAAQ,eAA9B;AACD;;AAED,OAAO,cAAP,GAAwB,cAAxB;;kBAEe,M;;;ACrqBf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;ACvOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3EA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA",
"file": "generated.js",
"sourceRoot": "",
"sourcesContent": [
"(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})",
"import isReactNative from \"./isReactNative\";\n\n/**\n * Generate a fingerprint for a file which will be used the store the endpoint\n *\n * @param {File} file\n * @param {Object} options\n * @param {Function} callback\n */\nexport default function fingerprint(file, options, callback) {\n if (isReactNative()) {\n return callback(null, reactNativeFingerprint(file, options));\n }\n\n return callback(null, [\n \"tus-br\",\n file.name,\n file.type,\n file.size,\n file.lastModified,\n options.endpoint\n ].join(\"-\"));\n}\n\nfunction reactNativeFingerprint(file, options) {\n let exifHash = file.exif ? hashCode(JSON.stringify(file.exif)) : \"noexif\";\n return [\n \"tus-rn\",\n file.name || \"noname\",\n file.size || \"nosize\",\n exifHash,\n options.endpoint\n ].join(\"/\");\n}\n\nfunction hashCode(str) {\n // from https://stackoverflow.com/a/8831937/151666\n var hash = 0;\n if (str.length === 0) {\n return hash;\n }\n for (var i = 0; i < str.length; i++) {\n var char = str.charCodeAt(i);\n hash = ((hash << 5) - hash) + char;\n hash = hash & hash; // Convert to 32bit integer\n }\n return hash;\n}\n",
"const isCordova = () => typeof window != \"undefined\" && (\n typeof window.PhoneGap != \"undefined\" ||\n typeof window.Cordova != \"undefined\" ||\n typeof window.cordova != \"undefined\");\n\nexport default isCordova;\n",
"const isReactNative = () => (typeof navigator !== \"undefined\" &&\n typeof navigator.product === \"string\" &&\n navigator.product.toLowerCase() === \"reactnative\");\n\nexport default isReactNative;\n",
"/**\n * readAsByteArray converts a File object to a Uint8Array.\n * This function is only used on the Apache Cordova platform.\n * See https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/index.html#read-a-file\n */\nfunction readAsByteArray(chunk, callback) {\n let reader = new FileReader();\n reader.onload = () => {\n callback(null, new Uint8Array(reader.result));\n };\n reader.onerror = (err) => {\n callback(err);\n };\n reader.readAsArrayBuffer(chunk);\n}\n\nexport default readAsByteArray;\n",
"/* global window */\nimport URL from \"url-parse\";\n\nexport function newRequest() {\n return new window.XMLHttpRequest();\n}\n\nexport function resolveUrl(origin, link) {\n return new URL(link, origin).toString();\n}\n",
"import isReactNative from \"./isReactNative\";\nimport uriToBlob from \"./uriToBlob\";\nimport isCordova from \"./isCordova\";\nimport readAsByteArray from \"./readAsByteArray\";\n\nclass FileSource {\n constructor(file) {\n this._file = file;\n this.size = file.size;\n }\n\n slice(start, end, callback) {\n // In Apache Cordova applications, a File must be resolved using\n // FileReader instances, see\n // https://cordova.apache.org/docs/en/8.x/reference/cordova-plugin-file/index.html#read-a-file\n if (isCordova()) {\n readAsByteArray(this._file.slice(start, end), (err, chunk) => {\n if (err) return callback(err);\n\n callback(null, chunk);\n });\n return;\n }\n\n callback(null, this._file.slice(start, end));\n }\n\n close() {}\n}\n\nclass StreamSource {\n constructor(reader, chunkSize) {\n this._chunkSize = chunkSize;\n this._buffer = undefined;\n this._bufferOffset = 0;\n this._reader = reader;\n this._done = false;\n }\n\n slice(start, end, callback) {\n if (start < this._bufferOffset) {\n callback(new Error(\"Requested data is before the reader's current offset\"));\n return;\n }\n\n return this._readUntilEnoughDataOrDone(start, end, callback);\n }\n\n _readUntilEnoughDataOrDone(start, end, callback) {\n const hasEnoughData = end <= this._bufferOffset + len(this._buffer);\n if (this._done || hasEnoughData) {\n var value = this._getDataFromBuffer(start, end);\n callback(null, value, value == null ? this._done : false);\n return;\n }\n this._reader.read().then(({ value, done }) => {\n if (done) {\n this._done = true;\n } else if (this._buffer === undefined) {\n this._buffer = value;\n } else {\n this._buffer = concat(this._buffer, value);\n }\n\n this._readUntilEnoughDataOrDone(start, end, callback);\n }).catch(err => {\n callback(new Error(\"Error during read: \"+err));\n });\n }\n\n _getDataFromBuffer(start, end) {\n // Remove data from buffer before `start`.\n // Data might be reread from the buffer if an upload fails, so we can only\n // safely delete data when it comes *before* what is currently being read.\n if (start > this._bufferOffset) {\n this._buffer = this._buffer.slice(start - this._bufferOffset);\n this._bufferOffset = start;\n }\n // If the buffer is empty after removing old data, all data has been read.\n const hasAllDataBeenRead = len(this._buffer) === 0;\n if (this._done && hasAllDataBeenRead) {\n return null;\n }\n // We already removed data before `start`, so we just return the first\n // chunk from the buffer.\n return this._buffer.slice(0, end - start);\n }\n\n close() {\n if (this._reader.cancel) {\n this._reader.cancel();\n }\n }\n}\n\nfunction len(blobOrArray) {\n if (blobOrArray === undefined) return 0;\n if (blobOrArray.size !== undefined) return blobOrArray.size;\n return blobOrArray.length;\n}\n\n/*\n Typed arrays and blobs don't have a concat method.\n This function helps StreamSource accumulate data to reach chunkSize.\n*/\nfunction concat(a, b) {\n if (a.concat) { // Is `a` an Array?\n return a.concat(b);\n }\n if (a instanceof Blob) {\n return new Blob([a,b], {type: a.type});\n }\n if (a.set) { // Is `a` a typed array?\n var c = new a.constructor(a.length + b.length);\n c.set(a);\n c.set(b, a.length);\n return c;\n }\n throw new Error(\"Unknown data type\");\n}\n\nexport function getSource(input, chunkSize, callback) {\n // In React Native, when user selects a file, instead of a File or Blob,\n // you usually get a file object {} with a uri property that contains\n // a local path to the file. We use XMLHttpRequest to fetch\n // the file blob, before uploading with tus.\n if (isReactNative() && input && typeof input.uri !== \"undefined\") {\n uriToBlob(input.uri, (err, blob) => {\n if (err) {\n return callback(new Error(\"tus: cannot fetch `file.uri` as Blob, make sure the uri is correct and accessible. \" + err));\n }\n callback(null, new FileSource(blob));\n });\n return;\n }\n\n // Since we emulate the Blob type in our tests (not all target browsers\n // support it), we cannot use `instanceof` for testing whether the input value\n // can be handled. Instead, we simply check is the slice() function and the\n // size property are available.\n if (typeof input.slice === \"function\" && typeof input.size !== \"undefined\") {\n callback(null, new FileSource(input));\n return;\n }\n\n if (typeof input.read === \"function\") {\n chunkSize = +chunkSize;\n if (!isFinite(chunkSize)) {\n callback(new Error(\"cannot create source for stream without a finite value for the `chunkSize` option\"));\n return;\n }\n callback(null, new StreamSource(input, chunkSize));\n return;\n }\n\n callback(new Error(\"source object may only be an instance of File, Blob, or Reader in this environment\"));\n}\n",
"/* global window, localStorage */\n\nlet hasStorage = false;\ntry {\n hasStorage = \"localStorage\" in window;\n\n // Attempt to store and read entries from the local storage to detect Private\n // Mode on Safari on iOS (see #49)\n var key = \"tusSupport\";\n localStorage.setItem(key, localStorage.getItem(key));\n\n} catch (e) {\n // If we try to access localStorage inside a sandboxed iframe, a SecurityError\n // is thrown. When in private mode on iOS Safari, a QuotaExceededError is\n // thrown (see #49)\n if (e.code === e.SECURITY_ERR || e.code === e.QUOTA_EXCEEDED_ERR) {\n hasStorage = false;\n } else {\n throw e;\n }\n}\n\nexport const canStoreURLs = hasStorage;\n\nclass LocalStorage {\n setItem(key, value, cb) {\n cb(null, localStorage.setItem(key, value));\n }\n\n getItem(key, cb) {\n cb(null, localStorage.getItem(key));\n }\n\n removeItem(key, cb) {\n cb(null, localStorage.removeItem(key));\n }\n}\n\nexport function getStorage() {\n return hasStorage ? new LocalStorage() : null;\n}\n",
"/**\n * uriToBlob resolves a URI to a Blob object. This is used for\n * React Native to retrieve a file (identified by a file://\n * URI) as a blob.\n */\nfunction uriToBlob(uri, done) {\n const xhr = new XMLHttpRequest();\n xhr.responseType = \"blob\";\n xhr.onload = () => {\n const blob = xhr.response;\n done(null, blob);\n };\n xhr.onerror = (err) => {\n done(err);\n };\n xhr.open(\"GET\", uri);\n xhr.send();\n}\n\nexport default uriToBlob;\n",
"class DetailedError extends Error {\n constructor(error, causingErr = null, xhr = null) {\n super(error.message);\n\n this.originalRequest = xhr;\n this.causingError = causingErr;\n\n let message = error.message;\n if (causingErr != null) {\n message += `, caused by ${causingErr.toString()}`;\n }\n if (xhr != null) {\n message += `, originated from request (response code: ${xhr.status}, response text: ${xhr.responseText})`;\n }\n this.message = message;\n }\n}\n\nexport default DetailedError;\n",
"/* global window */\nimport Upload from \"./upload\";\nimport * as storage from \"./node/storage\";\n\nconst {defaultOptions} = Upload;\n\nconst moduleExport = {\n Upload,\n canStoreURLs: storage.canStoreURLs,\n defaultOptions\n};\n\nif (typeof window !== \"undefined\") {\n // Browser environment using XMLHttpRequest\n const {XMLHttpRequest, Blob} = window;\n\n moduleExport.isSupported = (\n XMLHttpRequest &&\n Blob &&\n typeof Blob.prototype.slice === \"function\"\n );\n} else {\n // Node.js environment using http module\n moduleExport.isSupported = true;\n // make FileStorage module available as it will not be set by default.\n moduleExport.FileStorage = storage.FileStorage;\n}\n\n// The usage of the commonjs exporting syntax instead of the new ECMAScript\n// one is actually inteded and prevents weird behaviour if we are trying to\n// import this module in another module using Babel.\nmodule.exports = moduleExport;\n",
"/* global window */\nimport DetailedError from \"./error\";\nimport extend from \"extend\";\nimport { Base64 } from \"js-base64\";\n\n// We import the files used inside the Node environment which are rewritten\n// for browsers using the rules defined in the package.json\nimport { newRequest, resolveUrl } from \"./node/request\";\nimport { getSource } from \"./node/source\";\nimport { getStorage } from \"./node/storage\";\nimport fingerprint from \"./node/fingerprint\";\n\nconst defaultOptions = {\n endpoint: null,\n fingerprint,\n resume: true,\n onProgress: null,\n onChunkComplete: null,\n onSuccess: null,\n onError: null,\n headers: {},\n chunkSize: Infinity,\n withCredentials: false,\n uploadUrl: null,\n uploadSize: null,\n overridePatchMethod: false,\n retryDelays: null,\n removeFingerprintOnSuccess: false,\n uploadLengthDeferred: false,\n urlStorage: null,\n fileReader: null,\n uploadDataDuringCreation: false\n};\n\nclass Upload {\n constructor(file, options) {\n this.options = extend(true, {}, defaultOptions, options);\n\n // The storage module used to store URLs\n this._storage = this.options.urlStorage;\n\n // The underlying File/Blob object\n this.file = file;\n\n // The URL against which the file will be uploaded\n this.url = null;\n\n // The underlying XHR object for the current PATCH request\n this._xhr = null;\n\n // The fingerpinrt for the current file (set after start())\n this._fingerprint = null;\n\n // The offset used in the current PATCH request\n this._offset = null;\n\n // True if the current PATCH request has been aborted\n this._aborted = false;\n\n // The file's size in bytes\n this._size = null;\n\n // The Source object which will wrap around the given file and provides us\n // with a unified interface for getting its size and slice chunks from its\n // content allowing us to easily handle Files, Blobs, Buffers and Streams.\n this._source = null;\n\n // The current count of attempts which have been made. Null indicates none.\n this._retryAttempt = 0;\n\n // The timeout's ID which is used to delay the next retry\n this._retryTimeout = null;\n\n // The offset of the remote upload before the latest attempt was started.\n this._offsetBeforeRetry = 0;\n }\n\n static terminate(url, options, cb) {\n if (typeof options !== \"function\" && typeof cb !== \"function\") {\n throw new Error(\"tus: a callback function must be specified\");\n }\n\n if (typeof options === \"function\") {\n cb = options;\n options = {};\n }\n\n let xhr = newRequest();\n xhr.open(\"DELETE\", url, true);\n\n xhr.onload = () => {\n if (xhr.status !== 204) {\n cb(new DetailedError(new Error(\"tus: unexpected response while terminating upload\"), null, xhr));\n return;\n }\n\n cb();\n };\n\n xhr.onerror = (err) => {\n cb(new DetailedError(err, new Error(\"tus: failed to terminate upload\"), xhr));\n };\n\n setupXHR(xhr, options);\n xhr.send(null);\n }\n\n start() {\n let file = this.file;\n\n if (!file) {\n this._emitError(new Error(\"tus: no file or stream to upload provided\"));\n return;\n }\n\n if (!this.options.endpoint && !this.options.uploadUrl) {\n this._emitError(new Error(\"tus: neither an endpoint or an upload URL is provided\"));\n return;\n }\n\n if (this.options.resume && this._storage == null) {\n this._storage = getStorage();\n }\n\n if (this._source) {\n this._start(this._source);\n } else {\n const fileReader = this.options.fileReader || getSource;\n fileReader(file, this.options.chunkSize, (err, source) => {\n if (err) {\n this._emitError(err);\n return;\n }\n\n this._source = source;\n this._start(source);\n });\n }\n }\n\n _start(source) {\n let file = this.file;\n\n // First, we look at the uploadLengthDeferred option.\n // Next, we check if the caller has supplied a manual upload size.\n // Finally, we try to use the calculated size from the source object.\n if (this.options.uploadLengthDeferred) {\n this._size = null;\n } else if (this.options.uploadSize != null) {\n this._size = +this.options.uploadSize;\n if (isNaN(this._size)) {\n this._emitError(new Error(\"tus: cannot convert `uploadSize` option into a number\"));\n return;\n }\n } else {\n this._size = source.size;\n if (this._size == null) {\n this._emitError(new Error(\"tus: cannot automatically derive upload's size from input and must be specified manually using the `uploadSize` option\"));\n return;\n }\n }\n\n let retryDelays = this.options.retryDelays;\n if (retryDelays != null) {\n if (Object.prototype.toString.call(retryDelays) !== \"[object Array]\") {\n this._emitError(new Error(\"tus: the `retryDelays` option must either be an array or null\"));\n return;\n } else {\n let errorCallback = this.options.onError;\n this.options.onError = (err) => {\n // Restore the original error callback which may have been set.\n this.options.onError = errorCallback;\n\n // We will reset the attempt counter if\n // - we were already able to connect to the server (offset != null) and\n // - we were able to upload a small chunk of data to the server\n let shouldResetDelays = this._offset != null && (this._offset > this._offsetBeforeRetry);\n if (shouldResetDelays) {\n this._retryAttempt = 0;\n }\n\n let isOnline = true;\n if (typeof window !== \"undefined\" &&\n \"navigator\" in window &&\n window.navigator.onLine === false) {\n isOnline = false;\n }\n\n // We only attempt a retry if\n // - we didn't exceed the maxium number of retries, yet, and\n // - this error was caused by a request or it's response and\n // - the error is server error (i.e. no a status 4xx or a 409 or 423) and\n // - the browser does not indicate that we are offline\n let status = err.originalRequest ? err.originalRequest.status : 0;\n let isServerError = !inStatusCategory(status, 400) || status === 409 || status === 423;\n let shouldRetry = this._retryAttempt < retryDelays.length &&\n err.originalRequest != null &&\n isServerError &&\n isOnline;\n\n if (!shouldRetry) {\n this._emitError(err);\n return;\n }\n\n let delay = retryDelays[this._retryAttempt++];\n\n this._offsetBeforeRetry = this._offset;\n this.options.uploadUrl = this.url;\n\n this._retryTimeout = setTimeout(() => {\n this.start();\n }, delay);\n };\n }\n }\n\n // Reset the aborted flag when the upload is started or else the\n // _startUpload will stop before sending a request if the upload has been\n // aborted previously.\n this._aborted = false;\n\n // The upload had been started previously and we should reuse this URL.\n if (this.url != null) {\n this._resumeUpload();\n return;\n }\n\n // A URL has manually been specified, so we try to resume\n if (this.options.uploadUrl != null) {\n this.url = this.options.uploadUrl;\n this._resumeUpload();\n return;\n }\n\n // Try to find the endpoint for the file in the storage\n if (this._hasStorage()) {\n this.options.fingerprint(file, this.options, (err, fingerprintValue) => {\n if (err) {\n this._emitError(err);\n return;\n }\n\n this._fingerprint = fingerprintValue;\n this._storage.getItem(this._fingerprint, (err, resumedUrl) => {\n if (err) {\n this._emitError(err);\n return;\n }\n\n if (resumedUrl != null) {\n this.url = resumedUrl;\n this._resumeUpload();\n } else {\n this._createUpload();\n }\n });\n });\n } else {\n // An upload has not started for the file yet, so we start a new one\n this._createUpload();\n }\n }\n\n abort(shouldTerminate, cb) {\n if (this._xhr !== null) {\n this._xhr.abort();\n this._source.close();\n }\n this._aborted = true;\n\n if (this._retryTimeout != null) {\n clearTimeout(this._retryTimeout);\n this._retryTimeout = null;\n }\n\n cb = cb || function () {};\n if (shouldTerminate) {\n Upload.terminate(this.url, this.options, (err, xhr) => {\n if (err) {\n return cb(err, xhr);\n }\n\n this._hasStorage() ? this._storage.removeItem(this._fingerprint, cb) : cb();\n });\n } else {\n cb();\n }\n }\n\n _hasStorage() {\n return this.options.resume && this._storage;\n }\n\n _emitXhrError(xhr, err, causingErr) {\n this._emitError(new DetailedError(err, causingErr, xhr));\n }\n\n _emitError(err) {\n if (typeof this.options.onError === \"function\") {\n this.options.onError(err);\n } else {\n throw err;\n }\n }\n\n _emitSuccess() {\n if (typeof this.options.onSuccess === \"function\") {\n this.options.onSuccess();\n }\n }\n\n /**\n * Publishes notification when data has been sent to the server. This\n * data may not have been accepted by the server yet.\n * @param {number} bytesSent Number of bytes sent to the server.\n * @param {number} bytesTotal Total number of bytes to be sent to the server.\n */\n _emitProgress(bytesSent, bytesTotal) {\n if (typeof this.options.onProgress === \"function\") {\n this.options.onProgress(bytesSent, bytesTotal);\n }\n }\n\n /**\n * Publishes notification when a chunk of data has been sent to the server\n * and accepted by the server.\n * @param {number} chunkSize Size of the chunk that was accepted by the\n * server.\n * @param {number} bytesAccepted Total number of bytes that have been\n * accepted by the server.\n * @param {number} bytesTotal Total number of bytes to be sent to the server.\n */\n _emitChunkComplete(chunkSize, bytesAccepted, bytesTotal) {\n if (typeof this.options.onChunkComplete === \"function\") {\n this.options.onChunkComplete(chunkSize, bytesAccepted, bytesTotal);\n }\n }\n\n /**\n * Set the headers used in the request and the withCredentials property\n * as defined in the options\n *\n * @param {XMLHttpRequest} xhr\n */\n _setupXHR(xhr) {\n this._xhr = xhr;\n setupXHR(xhr, this.options);\n }\n\n /**\n * Create a new upload using the creation extension by sending a POST\n * request to the endpoint. After successful creation the file will be\n * uploaded\n *\n * @api private\n */\n _createUpload() {\n if (!this.options.endpoint) {\n this._emitError(new Error(\"tus: unable to create upload because no endpoint is provided\"));\n return;\n }\n\n let xhr = newRequest();\n xhr.open(\"POST\", this.options.endpoint, true);\n\n xhr.onload = () => {\n if (!inStatusCategory(xhr.status, 200)) {\n this._emitXhrError(xhr, new Error(\"tus: unexpected response while creating upload\"));\n return;\n }\n\n let location = xhr.getResponseHeader(\"Location\");\n if (location == null) {\n this._emitXhrError(xhr, new Error(\"tus: invalid or missing Location header\"));\n return;\n }\n\n this.url = resolveUrl(this.options.endpoint, location);\n\n if (this._size === 0) {\n // Nothing to upload and file was successfully created\n this._emitSuccess();\n this._source.close();\n return;\n }\n\n if (this._hasStorage()) {\n this._storage.setItem(this._fingerprint, this.url, (err) => {\n if (err) {\n this._emitError(err);\n }\n });\n }\n\n if (this.options.uploadDataDuringCreation) {\n this._handleUploadResponse(xhr);\n } else {\n this._offset = 0;\n this._startUpload();\n\n }\n };\n\n xhr.onerror = (err) => {\n this._emitXhrError(xhr, new Error(\"tus: failed to create upload\"), err);\n };\n\n this._setupXHR(xhr);\n if (this.options.uploadLengthDeferred) {\n xhr.setRequestHeader(\"Upload-Defer-Length\", 1);\n } else {\n xhr.setRequestHeader(\"Upload-Length\", this._size);\n }\n\n // Add metadata if values have been added\n var metadata = encodeMetadata(this.options.metadata);\n if (metadata !== \"\") {\n xhr.setRequestHeader(\"Upload-Metadata\", metadata);\n }\n\n if (this.options.uploadDataDuringCreation && !this.options.uploadLengthDeferred) {\n this._offset = 0;\n this._addChunkToRequest(xhr);\n } else {\n xhr.send(null);\n }\n }\n\n /*\n * Try to resume an existing upload. First a HEAD request will be sent\n * to retrieve the offset. If the request fails a new upload will be\n * created. In the case of a successful response the file will be uploaded.\n *\n * @api private\n */\n _resumeUpload() {\n let xhr = newRequest();\n xhr.open(\"HEAD\", this.url, true);\n\n xhr.onload = () => {\n if (!inStatusCategory(xhr.status, 200)) {\n if (this._hasStorage() && inStatusCategory(xhr.status, 400)) {\n // Remove stored fingerprint and corresponding endpoint,\n // on client errors since the file can not be found\n this._storage.removeItem(this._fingerprint, (err) => {\n if (err) {\n this._emitError(err);\n }\n });\n }\n\n // If the upload is locked (indicated by the 423 Locked status code), we\n // emit an error instead of directly starting a new upload. This way the\n // retry logic can catch the error and will retry the upload. An upload\n // is usually locked for a short period of time and will be available\n // afterwards.\n if (xhr.status === 423) {\n this._emitXhrError(xhr, new Error(\"tus: upload is currently locked; retry later\"));\n return;\n }\n\n if (!this.options.endpoint) {\n // Don't attempt to create a new upload if no endpoint is provided.\n this._emitXhrError(xhr, new Error(\"tus: unable to resume upload (new upload cannot be created without an endpoint)\"));\n return;\n }\n\n // Try to create a new upload\n this.url = null;\n this._createUpload();\n return;\n }\n\n let offset = parseInt(xhr.getResponseHeader(\"Upload-Offset\"), 10);\n if (isNaN(offset)) {\n this._emitXhrError(xhr, new Error(\"tus: invalid or missing offset value\"));\n return;\n }\n\n let length = parseInt(xhr.getResponseHeader(\"Upload-Length\"), 10);\n if (isNaN(length) && !this.options.uploadLengthDeferred) {\n this._emitXhrError(xhr, new Error(\"tus: invalid or missing length value\"));\n return;\n }\n\n // Upload has already been completed and we do not need to send additional\n // data to the server\n if (offset === length) {\n this._emitProgress(length, length);\n this._emitSuccess();\n return;\n }\n\n this._offset = offset;\n this._startUpload();\n };\n\n xhr.onerror = (err) => {\n this._emitXhrError(xhr, new Error(\"tus: failed to resume upload\"), err);\n };\n\n this._setupXHR(xhr);\n xhr.send(null);\n }\n\n /**\n * Start uploading the file using PATCH requests. The file will be divided\n * into chunks as specified in the chunkSize option. During the upload\n * the onProgress event handler may be invoked multiple times.\n *\n * @api private\n */\n _startUpload() {\n // If the upload has been aborted, we will not send the next PATCH request.\n // This is important if the abort method was called during a callback, such\n // as onChunkComplete or onProgress.\n if (this._aborted) {\n return;\n }\n\n let xhr = newRequest();\n\n // Some browser and servers may not support the PATCH method. For those\n // cases, you can tell tus-js-client to use a POST request with the\n // X-HTTP-Method-Override header for simulating a PATCH request.\n if (this.options.overridePatchMethod) {\n xhr.open(\"POST\", this.url, true);\n xhr.setRequestHeader(\"X-HTTP-Method-Override\", \"PATCH\");\n } else {\n xhr.open(\"PATCH\", this.url, true);\n }\n\n xhr.onload = () => {\n if (!inStatusCategory(xhr.status, 200)) {\n this._emitXhrError(xhr, new Error(\"tus: unexpected response while uploading chunk\"));\n return;\n }\n\n this._handleUploadResponse(xhr);\n };\n\n xhr.onerror = (err) => {\n // Don't emit an error if the upload was aborted manually\n if (this._aborted) {\n return;\n }\n\n this._emitXhrError(xhr, new Error(\"tus: failed to upload chunk at offset \" + this._offset), err);\n };\n\n this._setupXHR(xhr);\n\n xhr.setRequestHeader(\"Upload-Offset\", this._offset);\n this._addChunkToRequest(xhr);\n }\n\n /**\n * _addChunktoRequest reads a chunk from the source and sends it using the\n * supplied XHR object. It will not handle the response.\n */\n _addChunkToRequest(xhr) {\n // Test support for progress events before attaching an event listener\n if (\"upload\" in xhr) {\n xhr.upload.onprogress = (e) => {\n if (!e.lengthComputable) {\n return;\n }\n\n this._emitProgress(start + e.loaded, this._size);\n };\n }\n\n xhr.setRequestHeader(\"Content-Type\", \"application/offset+octet-stream\");\n\n let start = this._offset;\n let end = this._offset + this.options.chunkSize;\n\n // The specified chunkSize may be Infinity or the calcluated end position\n // may exceed the file's size. In both cases, we limit the end position to\n // the input's total size for simpler calculations and correctness.\n if ((end === Infinity || end > this._size) && !this.options.uploadLengthDeferred) {\n end = this._size;\n }\n\n this._source.slice(start, end, (err, value, complete) => {\n if (err) {\n this._emitError(err);\n return;\n }\n\n if (this.options.uploadLengthDeferred) {\n if (complete) {\n this._size = this._offset + (value && value.size ? value.size : 0);\n xhr.setRequestHeader(\"Upload-Length\", this._size);\n }\n }\n\n if (value === null) {\n xhr.send();\n } else {\n xhr.send(value);\n this._emitProgress(this._offset, this._size);\n }\n });\n }\n\n /**\n * _handleUploadResponse is used by requests that haven been sent using _addChunkToRequest\n * and already have received a response.\n */\n _handleUploadResponse(xhr) {\n let offset = parseInt(xhr.getResponseHeader(\"Upload-Offset\"), 10);\n if (isNaN(offset)) {\n this._emitXhrError(xhr, new Error(\"tus: invalid or missing offset value\"));\n return;\n }\n\n this._emitProgress(offset, this._size);\n this._emitChunkComplete(offset - this._offset, offset, this._size);\n\n this._offset = offset;\n\n if (offset == this._size) {\n if (this.options.removeFingerprintOnSuccess && this.options.resume) {\n // Remove stored fingerprint and corresponding endpoint. This causes\n // new upload of the same file must be treated as a different file.\n this._storage.removeItem(this._fingerprint, (err) => {\n if (err) {\n this._emitError(err);\n }\n });\n }\n\n // Yay, finally done :)\n this._emitSuccess();\n this._source.close();\n return;\n }\n\n this._startUpload();\n }\n}\n\nfunction encodeMetadata(metadata) {\n var encoded = [];\n\n for (var key in metadata) {\n encoded.push(key + \" \" + Base64.encode(metadata[key]));\n }\n\n return encoded.join(\",\");\n}\n\n/**\n * Checks whether a given status is in the range of the expected category.\n * For example, only a status between 200 and 299 will satisfy the category 200.\n *\n * @api private\n */\nfunction inStatusCategory(status, category) {\n return (status >= category && status < (category + 100));\n}\n\nfunction setupXHR(xhr, options) {\n xhr.setRequestHeader(\"Tus-Resumable\", \"1.0.0\");\n let headers = options.headers || {};\n\n for (let name in headers) {\n xhr.setRequestHeader(name, headers[name]);\n }\n\n xhr.withCredentials = options.withCredentials;\n}\n\nUpload.defaultOptions = defaultOptions;\n\nexport default Upload;\n",
"'use strict';\n\nvar hasOwn = Object.prototype.hasOwnProperty;\nvar toStr = Object.prototype.toString;\nvar defineProperty = Object.defineProperty;\nvar gOPD = Object.getOwnPropertyDescriptor;\n\nvar isArray = function isArray(arr) {\n\tif (typeof Array.isArray === 'function') {\n\t\treturn Array.isArray(arr);\n\t}\n\n\treturn toStr.call(arr) === '[object Array]';\n};\n\nvar isPlainObject = function isPlainObject(obj) {\n\tif (!obj || toStr.call(obj) !== '[object Object]') {\n\t\treturn false;\n\t}\n\n\tvar hasOwnConstructor = hasOwn.call(obj, 'constructor');\n\tvar hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');\n\t// Not own constructor property must be Object\n\tif (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {\n\t\treturn false;\n\t}\n\n\t// Own properties are enumerated firstly, so to speed up,\n\t// if last one is own, then all properties are own.\n\tvar key;\n\tfor (key in obj) { /**/ }\n\n\treturn typeof key === 'undefined' || hasOwn.call(obj, key);\n};\n\n// If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target\nvar setProperty = function setProperty(target, options) {\n\tif (defineProperty && options.name === '__proto__') {\n\t\tdefineProperty(target, options.name, {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t\tvalue: options.newValue,\n\t\t\twritable: true\n\t\t});\n\t} else {\n\t\ttarget[options.name] = options.newValue;\n\t}\n};\n\n// Return undefined instead of __proto__ if '__proto__' is not an own property\nvar getProperty = function getProperty(obj, name) {\n\tif (name === '__proto__') {\n\t\tif (!hasOwn.call(obj, name)) {\n\t\t\treturn void 0;\n\t\t} else if (gOPD) {\n\t\t\t// In early versions of node, obj['__proto__'] is buggy when obj has\n\t\t\t// __proto__ as an own property. Object.getOwnPropertyDescriptor() works.\n\t\t\treturn gOPD(obj, name).value;\n\t\t}\n\t}\n\n\treturn obj[name];\n};\n\nmodule.exports = function extend() {\n\tvar options, name, src, copy, copyIsArray, clone;\n\tvar target = arguments[0];\n\tvar i = 1;\n\tvar length = arguments.length;\n\tvar deep = false;\n\n\t// Handle a deep copy situation\n\tif (typeof target === 'boolean') {\n\t\tdeep = target;\n\t\ttarget = arguments[1] || {};\n\t\t// skip the boolean and the target\n\t\ti = 2;\n\t}\n\tif (target == null || (typeof target !== 'object' && typeof target !== 'function')) {\n\t\ttarget = {};\n\t}\n\n\tfor (; i < length; ++i) {\n\t\toptions = arguments[i];\n\t\t// Only deal with non-null/undefined values\n\t\tif (options != null) {\n\t\t\t// Extend the base object\n\t\t\tfor (name in options) {\n\t\t\t\tsrc = getProperty(target, name);\n\t\t\t\tcopy = getProperty(options, name);\n\n\t\t\t\t// Prevent never-ending loop\n\t\t\t\tif (target !== copy) {\n\t\t\t\t\t// Recurse if we're merging plain objects or arrays\n\t\t\t\t\tif (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {\n\t\t\t\t\t\tif (copyIsArray) {\n\t\t\t\t\t\t\tcopyIsArray = false;\n\t\t\t\t\t\t\tclone = src && isArray(src) ? src : [];\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tclone = src && isPlainObject(src) ? src : {};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Never move original objects, clone them\n\t\t\t\t\t\tsetProperty(target, { name: name, newValue: extend(deep, clone, copy) });\n\n\t\t\t\t\t// Don't bring in undefined values\n\t\t\t\t\t} else if (typeof copy !== 'undefined') {\n\t\t\t\t\t\tsetProperty(target, { name: name, newValue: copy });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Return the modified object\n\treturn target;\n};\n",
"/*\n * base64.js\n *\n * Licensed under the BSD 3-Clause License.\n * http://opensource.org/licenses/BSD-3-Clause\n *\n * References:\n * http://en.wikipedia.org/wiki/Base64\n */\n;(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined'\n ? module.exports = factory(global)\n : typeof define === 'function' && define.amd\n ? define(factory) : factory(global)\n}((\n typeof self !== 'undefined' ? self\n : typeof window !== 'undefined' ? window\n : typeof global !== 'undefined' ? global\n: this\n), function(global) {\n 'use strict';\n // existing version for noConflict()\n var _Base64 = global.Base64;\n var version = \"2.4.9\";\n // if node.js and NOT React Native, we use Buffer\n var buffer;\n if (typeof module !== 'undefined' && module.exports) {\n try {\n buffer = eval(\"require('buffer').Buffer\");\n } catch (err) {\n buffer = undefined;\n }\n }\n // constants\n var b64chars\n = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n var b64tab = function(bin) {\n var t = {};\n for (var i = 0, l = bin.length; i < l; i++) t[bin.charAt(i)] = i;\n return t;\n }(b64chars);\n var fromCharCode = String.fromCharCode;\n // encoder stuff\n var cb_utob = function(c) {\n if (c.length < 2) {\n var cc = c.charCodeAt(0);\n return cc < 0x80 ? c\n : cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6))\n + fromCharCode(0x80 | (cc & 0x3f)))\n : (fromCharCode(0xe0 | ((cc >>> 12) & 0x0f))\n + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))\n + fromCharCode(0x80 | ( cc & 0x3f)));\n } else {\n var cc = 0x10000\n + (c.charCodeAt(0) - 0xD800) * 0x400\n + (c.charCodeAt(1) - 0xDC00);\n return (fromCharCode(0xf0 | ((cc >>> 18) & 0x07))\n + fromCharCode(0x80 | ((cc >>> 12) & 0x3f))\n + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))\n + fromCharCode(0x80 | ( cc & 0x3f)));\n }\n };\n var re_utob = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFFF]|[^\\x00-\\x7F]/g;\n var utob = function(u) {\n return u.replace(re_utob, cb_utob);\n };\n var cb_encode = function(ccc) {\n var padlen = [0, 2, 1][ccc.length % 3],\n ord = ccc.charCodeAt(0) << 16\n | ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8)\n | ((ccc.length > 2 ? ccc.charCodeAt(2) : 0)),\n chars = [\n b64chars.charAt( ord >>> 18),\n b64chars.charAt((ord >>> 12) & 63),\n padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),\n padlen >= 1 ? '=' : b64chars.charAt(ord & 63)\n ];\n return chars.join('');\n };\n var btoa = global.btoa ? function(b) {\n return global.btoa(b);\n } : function(b) {\n return b.replace(/[\\s\\S]{1,3}/g, cb_encode);\n };\n var _encode = buffer ?\n buffer.from && Uint8Array && buffer.from !== Uint8Array.from\n ? function (u) {\n return (u.constructor === buffer.constructor ? u : buffer.from(u))\n .toString('base64')\n }\n : function (u) {\n return (u.constructor === buffer.constructor ? u : new buffer(u))\n .toString('base64')\n }\n : function (u) { return btoa(utob(u)) }\n ;\n var encode = function(u, urisafe) {\n return !urisafe\n ? _encode(String(u))\n : _encode(String(u)).replace(/[+\\/]/g, function(m0) {\n return m0 == '+' ? '-' : '_';\n }).replace(/=/g, '');\n };\n var encodeURI = function(u) { return encode(u, true) };\n // decoder stuff\n var re_btou = new RegExp([\n '[\\xC0-\\xDF][\\x80-\\xBF]',\n '[\\xE0-\\xEF][\\x80-\\xBF]{2}',\n '[\\xF0-\\xF7][\\x80-\\xBF]{3}'\n ].join('|'), 'g');\n var cb_btou = function(cccc) {\n switch(cccc.length) {\n case 4:\n var cp = ((0x07 & cccc.charCodeAt(0)) << 18)\n | ((0x3f & cccc.charCodeAt(1)) << 12)\n | ((0x3f & cccc.charCodeAt(2)) << 6)\n | (0x3f & cccc.charCodeAt(3)),\n offset = cp - 0x10000;\n return (fromCharCode((offset >>> 10) + 0xD800)\n + fromCharCode((offset & 0x3FF) + 0xDC00));\n case 3:\n return fromCharCode(\n ((0x0f & cccc.charCodeAt(0)) << 12)\n | ((0x3f & cccc.charCodeAt(1)) << 6)\n | (0x3f & cccc.charCodeAt(2))\n );\n default:\n return fromCharCode(\n ((0x1f & cccc.charCodeAt(0)) << 6)\n | (0x3f & cccc.charCodeAt(1))\n );\n }\n };\n var btou = function(b) {\n return b.replace(re_btou, cb_btou);\n };\n var cb_decode = function(cccc) {\n var len = cccc.length,\n padlen = len % 4,\n n = (len > 0 ? b64tab[cccc.charAt(0)] << 18 : 0)\n | (len > 1 ? b64tab[cccc.charAt(1)] << 12 : 0)\n | (len > 2 ? b64tab[cccc.charAt(2)] << 6 : 0)\n | (len > 3 ? b64tab[cccc.charAt(3)] : 0),\n chars = [\n fromCharCode( n >>> 16),\n fromCharCode((n >>> 8) & 0xff),\n fromCharCode( n & 0xff)\n ];\n chars.length -= [0, 0, 2, 1][padlen];\n return chars.join('');\n };\n var atob = global.atob ? function(a) {\n return global.atob(a);\n } : function(a){\n return a.replace(/[\\s\\S]{1,4}/g, cb_decode);\n };\n var _decode = buffer ?\n buffer.from && Uint8Array && buffer.from !== Uint8Array.from\n ? function(a) {\n return (a.constructor === buffer.constructor\n ? a : buffer.from(a, 'base64')).toString();\n }\n : function(a) {\n return (a.constructor === buffer.constructor\n ? a : new buffer(a, 'base64')).toString();\n }\n : function(a) { return btou(atob(a)) };\n var decode = function(a){\n return _decode(\n String(a).replace(/[-_]/g, function(m0) { return m0 == '-' ? '+' : '/' })\n .replace(/[^A-Za-z0-9\\+\\/]/g, '')\n );\n };\n var noConflict = function() {\n var Base64 = global.Base64;\n global.Base64 = _Base64;\n return Base64;\n };\n // export Base64\n global.Base64 = {\n VERSION: version,\n atob: atob,\n btoa: btoa,\n fromBase64: decode,\n toBase64: encode,\n utob: utob,\n encode: encode,\n encodeURI: encodeURI,\n btou: btou,\n decode: decode,\n noConflict: noConflict,\n __buffer__: buffer\n };\n // if ES5 is available, make Base64.extendString() available\n if (typeof Object.defineProperty === 'function') {\n var noEnum = function(v){\n return {value:v,enumerable:false,writable:true,configurable:true};\n };\n global.Base64.extendString = function () {\n Object.defineProperty(\n String.prototype, 'fromBase64', noEnum(function () {\n return decode(this)\n }));\n Object.defineProperty(\n String.prototype, 'toBase64', noEnum(function (urisafe) {\n return encode(this, urisafe)\n }));\n Object.defineProperty(\n String.prototype, 'toBase64URI', noEnum(function () {\n return encode(this, true)\n }));\n };\n }\n //\n // export Base64 to the namespace\n //\n if (global['Meteor']) { // Meteor.js\n Base64 = global.Base64;\n }\n // module.exports and AMD are mutually exclusive.\n // module.exports has precedence.\n if (typeof module !== 'undefined' && module.exports) {\n module.exports.Base64 = global.Base64;\n }\n else if (typeof define === 'function' && define.amd) {\n // AMD. Register as an anonymous module.\n define([], function(){ return global.Base64 });\n }\n // that's it!\n return {Base64: global.Base64}\n}));\n",
"'use strict';\n\nvar has = Object.prototype.hasOwnProperty;\n\n/**\n * Decode a URI encoded string.\n *\n * @param {String} input The URI encoded string.\n * @returns {String} The decoded string.\n * @api private\n */\nfunction decode(input) {\n return decodeURIComponent(input.replace(/\\+/g, ' '));\n}\n\n/**\n * Simple query string parser.\n *\n * @param {String} query The query string that needs to be parsed.\n * @returns {Object}\n * @api public\n */\nfunction querystring(query) {\n var parser = /([^=?&]+)=?([^&]*)/g\n , result = {}\n , part;\n\n while (part = parser.exec(query)) {\n var key = decode(part[1])\n , value = decode(part[2]);\n\n //\n // Prevent overriding of existing properties. This ensures that build-in\n // methods like `toString` or __proto__ are not overriden by malicious\n // querystrings.\n //\n if (key in result) continue;\n result[key] = value;\n }\n\n return result;\n}\n\n/**\n * Transform a query string to an object.\n *\n * @param {Object} obj Object that should be transformed.\n * @param {String} prefix Optional prefix.\n * @returns {String}\n * @api public\n */\nfunction querystringify(obj, prefix) {\n prefix = prefix || '';\n\n var pairs = [];\n\n //\n // Optionally prefix with a '?' if needed\n //\n if ('string' !== typeof prefix) prefix = '?';\n\n for (var key in obj) {\n if (has.call(obj, key)) {\n pairs.push(encodeURIComponent(key) +'='+ encodeURIComponent(obj[key]));\n }\n }\n\n return pairs.length ? prefix + pairs.join('&') : '';\n}\n\n//\n// Expose the module.\n//\nexports.stringify = querystringify;\nexports.parse = querystring;\n",
"'use strict';\n\n/**\n * Check if we're required to add a port number.\n *\n * @see https://url.spec.whatwg.org/#default-port\n * @param {Number|String} port Port number we need to check\n * @param {String} protocol Protocol we need to check against.\n * @returns {Boolean} Is it a default port for the given protocol\n * @api private\n */\nmodule.exports = function required(port, protocol) {\n protocol = protocol.split(':')[0];\n port = +port;\n\n if (!port) return false;\n\n switch (protocol) {\n case 'http':\n case 'ws':\n return port !== 80;\n\n case 'https':\n case 'wss':\n return port !== 443;\n\n case 'ftp':\n return port !== 21;\n\n case 'gopher':\n return port !== 70;\n\n case 'file':\n return false;\n }\n\n return port !== 0;\n};\n",
"'use strict';\n\nvar required = require('requires-port')\n , qs = require('querystringify')\n , protocolre = /^([a-z][a-z0-9.+-]*:)?(\\/\\/)?([\\S\\s]*)/i\n , slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\\/\\//;\n\n/**\n * These are the parse rules for the URL parser, it informs the parser\n * about:\n *\n * 0. The char it Needs to parse, if it's a string it should be done using\n * indexOf, RegExp using exec and NaN means set as current value.\n * 1. The property we should set when parsing this value.\n * 2. Indication if it's backwards or forward parsing, when set as number it's\n * the value of extra chars that should be split off.\n * 3. Inherit from location if non existing in the parser.\n * 4. `toLowerCase` the resulting value.\n */\nvar rules = [\n ['#', 'hash'], // Extract from the back.\n ['?', 'query'], // Extract from the back.\n function sanitize(address) { // Sanitize what is left of the address\n return address.replace('\\\\', '/');\n },\n ['/', 'pathname'], // Extract from the back.\n ['@', 'auth', 1], // Extract from the front.\n [NaN, 'host', undefined, 1, 1], // Set left over value.\n [/:(\\d+)$/, 'port', undefined, 1], // RegExp the back.\n [NaN, 'hostname', undefined, 1, 1] // Set left over.\n];\n\n/**\n * These properties should not be copied or inherited from. This is only needed\n * for all non blob URL's as a blob URL does not include a hash, only the\n * origin.\n *\n * @type {Object}\n * @private\n */\nvar ignore = { hash: 1, query: 1 };\n\n/**\n * The location object differs when your code is loaded through a normal page,\n * Worker or through a worker using a blob. And with the blobble begins the\n * trouble as the location object will contain the URL of the blob, not the\n * location of the page where our code is loaded in. The actual origin is\n * encoded in the `pathname` so we can thankfully generate a good \"default\"\n * location from it so we can generate proper relative URL's again.\n *\n * @param {Object|String} loc Optional default location object.\n * @returns {Object} lolcation object.\n * @public\n */\nfunction lolcation(loc) {\n var location = global && global.location || {};\n loc = loc || location;\n\n var finaldestination = {}\n , type = typeof loc\n , key;\n\n if ('blob:' === loc.protocol) {\n finaldestination = new Url(unescape(loc.pathname), {});\n } else if ('string' === type) {\n finaldestination = new Url(loc, {});\n for (key in ignore) delete finaldestination[key];\n } else if ('object' === type) {\n for (key in loc) {\n if (key in ignore) continue;\n finaldestination[key] = loc[key];\n }\n\n if (finaldestination.slashes === undefined) {\n finaldestination.slashes = slashes.test(loc.href);\n }\n }\n\n return finaldestination;\n}\n\n/**\n * @typedef ProtocolExtract\n * @type Object\n * @property {String} protocol Protocol matched in the URL, in lowercase.\n * @property {Boolean} slashes `true` if protocol is followed by \"//\", else `false`.\n * @property {String} rest Rest of the URL that is not part of the protocol.\n */\n\n/**\n * Extract protocol information from a URL with/without double slash (\"//\").\n *\n * @param {String} address URL we want to extract from.\n * @return {ProtocolExtract} Extracted information.\n * @private\n */\nfunction extractProtocol(address) {\n var match = protocolre.exec(address);\n\n return {\n protocol: match[1] ? match[1].toLowerCase() : '',\n slashes: !!match[2],\n rest: match[3]\n };\n}\n\n/**\n * Resolve a relative URL pathname against a base URL pathname.\n *\n * @param {String} relative Pathname of the relative URL.\n * @param {String} base Pathname of the base URL.\n * @return {String} Resolved pathname.\n * @private\n */\nfunction resolve(relative, base) {\n var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/'))\n , i = path.length\n , last = path[i - 1]\n , unshift = false\n , up = 0;\n\n while (i--) {\n if (path[i] === '.') {\n path.splice(i, 1);\n } else if (path[i] === '..') {\n path.splice(i, 1);\n up++;\n } else if (up) {\n if (i === 0) unshift = true;\n path.splice(i, 1);\n up--;\n }\n }\n\n if (unshift) path.unshift('');\n if (last === '.' || last === '..') path.push('');\n\n return path.join('/');\n}\n\n/**\n * The actual URL instance. Instead of returning an object we've opted-in to\n * create an actual constructor as it's much more memory efficient and\n * faster and it pleases my OCD.\n *\n * It is worth noting that we should not use `URL` as class name to prevent\n * clashes with the global URL instance that got introduced in browsers.\n *\n * @constructor\n * @param {String} address URL we want to parse.\n * @param {Object|String} location Location defaults for relative paths.\n * @param {Boolean|Function} parser Parser for the query string.\n * @private\n */\nfunction Url(address, location, parser) {\n if (!(this instanceof Url)) {\n return new Url(address, location, parser);\n }\n\n var relative, extracted, parse, instruction, index, key\n , instructions = rules.slice()\n , type = typeof location\n , url = this\n , i = 0;\n\n //\n // The following if statements allows this module two have compatibility with\n // 2 different API:\n //\n // 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments\n // where the boolean indicates that the query string should also be parsed.\n //\n // 2. The `URL` interface of the browser which accepts a URL, object as\n // arguments. The supplied object will be used as default values / fall-back\n // for relative paths.\n //\n if ('object' !== type && 'string' !== type) {\n parser = location;\n location = null;\n }\n\n if (parser && 'function' !== typeof parser) parser = qs.parse;\n\n location = lolcation(location);\n\n //\n // Extract protocol information before running the instructions.\n //\n extracted = extractProtocol(address || '');\n relative = !extracted.protocol && !extracted.slashes;\n url.slashes = extracted.slashes || relative && location.slashes;\n url.protocol = extracted.protocol || location.protocol || '';\n address = extracted.rest;\n\n //\n // When the authority component is absent the URL starts with a path\n // component.\n //\n if (!extracted.slashes) instructions[3] = [/(.*)/, 'pathname'];\n\n for (; i < instructions.length; i++) {\n instruction = instructions[i];\n\n if (typeof instruction === 'function') {\n address = instruction(address);\n continue;\n }\n\n parse = instruction[0];\n key = instruction[1];\n\n if (parse !== parse) {\n url[key] = address;\n } else if ('string' === typeof parse) {\n if (~(index = address.indexOf(parse))) {\n if ('number' === typeof instruction[2]) {\n url[key] = address.slice(0, index);\n address = address.slice(index + instruction[2]);\n } else {\n url[key] = address.slice(index);\n address = address.slice(0, index);\n }\n }\n } else if ((index = parse.exec(address))) {\n url[key] = index[1];\n address = address.slice(0, index.index);\n }\n\n url[key] = url[key] || (\n relative && instruction[3] ? location[key] || '' : ''\n );\n\n //\n // Hostname, host and protocol should be lowercased so they can be used to\n // create a proper `origin`.\n //\n if (instruction[4]) url[key] = url[key].toLowerCase();\n }\n\n //\n // Also parse the supplied query string in to an object. If we're supplied\n // with a custom parser as function use that instead of the default build-in\n // parser.\n //\n if (parser) url.query = parser(url.query);\n\n //\n // If the URL is relative, resolve the pathname against the base URL.\n //\n if (\n relative\n && location.slashes\n && url.pathname.charAt(0) !== '/'\n && (url.pathname !== '' || location.pathname !== '')\n ) {\n url.pathname = resolve(url.pathname, location.pathname);\n }\n\n //\n // We should not add port numbers if they are already the default port number\n // for a given protocol. As the host also contains the port number we're going\n // override it with the hostname which contains no port number.\n //\n if (!required(url.port, url.protocol)) {\n url.host = url.hostname;\n url.port = '';\n }\n\n //\n // Parse down the `auth` for the username and password.\n //\n url.username = url.password = '';\n if (url.auth) {\n instruction = url.auth.split(':');\n url.username = instruction[0] || '';\n url.password = instruction[1] || '';\n }\n\n url.origin = url.protocol && url.host && url.protocol !== 'file:'\n ? url.protocol +'//'+ url.host\n : 'null';\n\n //\n // The href is just the compiled result.\n //\n url.href = url.toString();\n}\n\n/**\n * This is convenience method for changing properties in the URL instance to\n * insure that they all propagate correctly.\n *\n * @param {String} part Property we need to adjust.\n * @param {Mixed} value The newly assigned value.\n * @param {Boolean|Function} fn When setting the query, it will be the function\n * used to parse the query.\n * When setting the protocol, double slash will be\n * removed from the final url if it is true.\n * @returns {URL} URL instance for chaining.\n * @public\n */\nfunction set(part, value, fn) {\n var url = this;\n\n switch (part) {\n case 'query':\n if ('string' === typeof value && value.length) {\n value = (fn || qs.parse)(value);\n }\n\n url[part] = value;\n break;\n\n case 'port':\n url[part] = value;\n\n if (!required(value, url.protocol)) {\n url.host = url.hostname;\n url[part] = '';\n } else if (value) {\n url.host = url.hostname +':'+ value;\n }\n\n break;\n\n case 'hostname':\n url[part] = value;\n\n if (url.port) value += ':'+ url.port;\n url.host = value;\n break;\n\n case 'host':\n url[part] = value;\n\n if (/:\\d+$/.test(value)) {\n value = value.split(':');\n url.port = value.pop();\n url.hostname = value.join(':');\n } else {\n url.hostname = value;\n url.port = '';\n }\n\n break;\n\n case 'protocol':\n url.protocol = value.toLowerCase();\n url.slashes = !fn;\n break;\n\n case 'pathname':\n case 'hash':\n if (value) {\n var char = part === 'pathname' ? '/' : '#';\n url[part] = value.charAt(0) !== char ? char + value : value;\n } else {\n url[part] = value;\n }\n break;\n\n default:\n url[part] = value;\n }\n\n for (var i = 0; i < rules.length; i++) {\n var ins = rules[i];\n\n if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();\n }\n\n url.origin = url.protocol && url.host && url.protocol !== 'file:'\n ? url.protocol +'//'+ url.host\n : 'null';\n\n url.href = url.toString();\n\n return url;\n}\n\n/**\n * Transform the properties back in to a valid and full URL string.\n *\n * @param {Function} stringify Optional query stringify function.\n * @returns {String} Compiled version of the URL.\n * @public\n */\nfunction toString(stringify) {\n if (!stringify || 'function' !== typeof stringify) stringify = qs.stringify;\n\n var query\n , url = this\n , protocol = url.protocol;\n\n if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':';\n\n var result = protocol + (url.slashes ? '//' : '');\n\n if (url.username) {\n result += url.username;\n if (url.password) result += ':'+ url.password;\n result += '@';\n }\n\n result += url.host + url.pathname;\n\n query = 'object' === typeof url.query ? stringify(url.query) : url.query;\n if (query) result += '?' !== query.charAt(0) ? '?'+ query : query;\n\n if (url.hash) result += url.hash;\n\n return result;\n}\n\nUrl.prototype = { set: set, toString: toString };\n\n//\n// Expose the URL parser and some additional properties that might be useful for\n// others or testing.\n//\nUrl.extractProtocol = extractProtocol;\nUrl.location = lolcation;\nUrl.qs = qs;\n\nmodule.exports = Url;\n"
]
}
\ No newline at end of file
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.tus=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(_dereq_,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=fingerprint;var _isReactNative=_dereq_("./isReactNative");var _isReactNative2=_interopRequireDefault(_isReactNative);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function fingerprint(file,options,callback){if((0,_isReactNative2.default)()){return callback(null,reactNativeFingerprint(file,options))}return callback(null,["tus-br",file.name,file.type,file.size,file.lastModified,options.endpoint].join("-"))}function reactNativeFingerprint(file,options){var exifHash=file.exif?hashCode(JSON.stringify(file.exif)):"noexif";return["tus-rn",file.name||"noname",file.size||"nosize",exifHash,options.endpoint].join("/")}function hashCode(str){var hash=0;if(str.length===0){return hash}for(var i=0;i<str.length;i++){var char=str.charCodeAt(i);hash=(hash<<5)-hash+char;hash=hash&hash}return hash}},{"./isReactNative":3}],2:[function(_dereq_,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var isCordova=function isCordova(){return typeof window!="undefined"&&(typeof window.PhoneGap!="undefined"||typeof window.Cordova!="undefined"||typeof window.cordova!="undefined")};exports.default=isCordova},{}],3:[function(_dereq_,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var isReactNative=function isReactNative(){return typeof navigator!=="undefined"&&typeof navigator.product==="string"&&navigator.product.toLowerCase()==="reactnative"};exports.default=isReactNative},{}],4:[function(_dereq_,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});function readAsByteArray(chunk,callback){var reader=new FileReader;reader.onload=function(){callback(null,new Uint8Array(reader.result))};reader.onerror=function(err){callback(err)};reader.readAsArrayBuffer(chunk)}exports.default=readAsByteArray},{}],5:[function(_dereq_,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.newRequest=newRequest;exports.resolveUrl=resolveUrl;var _urlParse=_dereq_("url-parse");var _urlParse2=_interopRequireDefault(_urlParse);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function newRequest(){return new window.XMLHttpRequest}function resolveUrl(origin,link){return new _urlParse2.default(link,origin).toString()}},{"url-parse":16}],6:[function(_dereq_,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();exports.getSource=getSource;var _isReactNative=_dereq_("./isReactNative");var _isReactNative2=_interopRequireDefault(_isReactNative);var _uriToBlob=_dereq_("./uriToBlob");var _uriToBlob2=_interopRequireDefault(_uriToBlob);var _isCordova=_dereq_("./isCordova");var _isCordova2=_interopRequireDefault(_isCordova);var _readAsByteArray=_dereq_("./readAsByteArray");var _readAsByteArray2=_interopRequireDefault(_readAsByteArray);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var FileSource=function(){function FileSource(file){_classCallCheck(this,FileSource);this._file=file;this.size=file.size}_createClass(FileSource,[{key:"slice",value:function slice(start,end,callback){if((0,_isCordova2.default)()){(0,_readAsByteArray2.default)(this._file.slice(start,end),function(err,chunk){if(err)return callback(err);callback(null,chunk)});return}callback(null,this._file.slice(start,end))}},{key:"close",value:function close(){}}]);return FileSource}();var StreamSource=function(){function StreamSource(reader,chunkSize){_classCallCheck(this,StreamSource);this._chunkSize=chunkSize;this._buffer=undefined;this._bufferOffset=0;this._reader=reader;this._done=false}_createClass(StreamSource,[{key:"slice",value:function slice(start,end,callback){if(start<this._bufferOffset){callback(new Error("Requested data is before the reader's current offset"));return}return this._readUntilEnoughDataOrDone(start,end,callback)}},{key:"_readUntilEnoughDataOrDone",value:function _readUntilEnoughDataOrDone(start,end,callback){var _this=this;var hasEnoughData=end<=this._bufferOffset+len(this._buffer);if(this._done||hasEnoughData){var value=this._getDataFromBuffer(start,end);callback(null,value,value==null?this._done:false);return}this._reader.read().then(function(_ref){var value=_ref.value,done=_ref.done;if(done){_this._done=true}else if(_this._buffer===undefined){_this._buffer=value}else{_this._buffer=concat(_this._buffer,value)}_this._readUntilEnoughDataOrDone(start,end,callback)}).catch(function(err){callback(new Error("Error during read: "+err))})}},{key:"_getDataFromBuffer",value:function _getDataFromBuffer(start,end){if(start>this._bufferOffset){this._buffer=this._buffer.slice(start-this._bufferOffset);this._bufferOffset=start}var hasAllDataBeenRead=len(this._buffer)===0;if(this._done&&hasAllDataBeenRead){return null}return this._buffer.slice(0,end-start)}},{key:"close",value:function close(){if(this._reader.cancel){this._reader.cancel()}}}]);return StreamSource}();function len(blobOrArray){if(blobOrArray===undefined)return 0;if(blobOrArray.size!==undefined)return blobOrArray.size;return blobOrArray.length}function concat(a,b){if(a.concat){return a.concat(b)}if(a instanceof Blob){return new Blob([a,b],{type:a.type})}if(a.set){var c=new a.constructor(a.length+b.length);c.set(a);c.set(b,a.length);return c}throw new Error("Unknown data type")}function getSource(input,chunkSize,callback){if((0,_isReactNative2.default)()&&input&&typeof input.uri!=="undefined"){(0,_uriToBlob2.default)(input.uri,function(err,blob){if(err){return callback(new Error("tus: cannot fetch `file.uri` as Blob, make sure the uri is correct and accessible. "+err))}callback(null,new FileSource(blob))});return}if(typeof input.slice==="function"&&typeof input.size!=="undefined"){callback(null,new FileSource(input));return}if(typeof input.read==="function"){chunkSize=+chunkSize;if(!isFinite(chunkSize)){callback(new Error("cannot create source for stream without a finite value for the `chunkSize` option"));return}callback(null,new StreamSource(input,chunkSize));return}callback(new Error("source object may only be an instance of File, Blob, or Reader in this environment"))}},{"./isCordova":2,"./isReactNative":3,"./readAsByteArray":4,"./uriToBlob":8}],7:[function(_dereq_,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();exports.getStorage=getStorage;function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var hasStorage=false;try{hasStorage="localStorage"in window;var key="tusSupport";localStorage.setItem(key,localStorage.getItem(key))}catch(e){if(e.code===e.SECURITY_ERR||e.code===e.QUOTA_EXCEEDED_ERR){hasStorage=false}else{throw e}}var canStoreURLs=exports.canStoreURLs=hasStorage;var LocalStorage=function(){function LocalStorage(){_classCallCheck(this,LocalStorage)}_createClass(LocalStorage,[{key:"setItem",value:function setItem(key,value,cb){cb(null,localStorage.setItem(key,value))}},{key:"getItem",value:function getItem(key,cb){cb(null,localStorage.getItem(key))}},{key:"removeItem",value:function removeItem(key,cb){cb(null,localStorage.removeItem(key))}}]);return LocalStorage}();function getStorage(){return hasStorage?new LocalStorage:null}},{}],8:[function(_dereq_,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});function uriToBlob(uri,done){var xhr=new XMLHttpRequest;xhr.responseType="blob";xhr.onload=function(){var blob=xhr.response;done(null,blob)};xhr.onerror=function(err){done(err)};xhr.open("GET",uri);xhr.send()}exports.default=uriToBlob},{}],9:[function(_dereq_,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}var DetailedError=function(_Error){_inherits(DetailedError,_Error);function DetailedError(error){var causingErr=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var xhr=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;_classCallCheck(this,DetailedError);var _this=_possibleConstructorReturn(this,(DetailedError.__proto__||Object.getPrototypeOf(DetailedError)).call(this,error.message));_this.originalRequest=xhr;_this.causingError=causingErr;var message=error.message;if(causingErr!=null){message+=", caused by "+causingErr.toString()}if(xhr!=null){message+=", originated from request (response code: "+xhr.status+", response text: "+xhr.responseText+")"}_this.message=message;return _this}return DetailedError}(Error);exports.default=DetailedError},{}],10:[function(_dereq_,module,exports){"use strict";var _upload=_dereq_("./upload");var _upload2=_interopRequireDefault(_upload);var _storage=_dereq_("./node/storage");var storage=_interopRequireWildcard(_storage);function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj.default=obj;return newObj}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var defaultOptions=_upload2.default.defaultOptions;var moduleExport={Upload:_upload2.default,canStoreURLs:storage.canStoreURLs,defaultOptions:defaultOptions};if(typeof window!=="undefined"){var _window=window,XMLHttpRequest=_window.XMLHttpRequest,Blob=_window.Blob;moduleExport.isSupported=XMLHttpRequest&&Blob&&typeof Blob.prototype.slice==="function"}else{moduleExport.isSupported=true;moduleExport.FileStorage=storage.FileStorage}module.exports=moduleExport},{"./node/storage":7,"./upload":11}],11:[function(_dereq_,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();var _error=_dereq_("./error");var _error2=_interopRequireDefault(_error);var _extend=_dereq_("extend");var _extend2=_interopRequireDefault(_extend);var _jsBase=_dereq_("js-base64");var _request=_dereq_("./node/request");var _source=_dereq_("./node/source");var _storage=_dereq_("./node/storage");var _fingerprint=_dereq_("./node/fingerprint");var _fingerprint2=_interopRequireDefault(_fingerprint);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var defaultOptions={endpoint:null,fingerprint:_fingerprint2.default,resume:true,onProgress:null,onChunkComplete:null,onSuccess:null,onError:null,headers:{},chunkSize:Infinity,withCredentials:false,uploadUrl:null,uploadSize:null,overridePatchMethod:false,retryDelays:null,removeFingerprintOnSuccess:false,uploadLengthDeferred:false,urlStorage:null,fileReader:null,uploadDataDuringCreation:false};var Upload=function(){function Upload(file,options){_classCallCheck(this,Upload);this.options=(0,_extend2.default)(true,{},defaultOptions,options);this._storage=this.options.urlStorage;this.file=file;this.url=null;this._xhr=null;this._fingerprint=null;this._offset=null;this._aborted=false;this._size=null;this._source=null;this._retryAttempt=0;this._retryTimeout=null;this._offsetBeforeRetry=0}_createClass(Upload,[{key:"start",value:function start(){var _this=this;var file=this.file;if(!file){this._emitError(new Error("tus: no file or stream to upload provided"));return}if(!this.options.endpoint&&!this.options.uploadUrl){this._emitError(new Error("tus: neither an endpoint or an upload URL is provided"));return}if(this.options.resume&&this._storage==null){this._storage=(0,_storage.getStorage)()}if(this._source){this._start(this._source)}else{var fileReader=this.options.fileReader||_source.getSource;fileReader(file,this.options.chunkSize,function(err,source){if(err){_this._emitError(err);return}_this._source=source;_this._start(source)})}}},{key:"_start",value:function _start(source){var _this2=this;var file=this.file;if(this.options.uploadLengthDeferred){this._size=null}else if(this.options.uploadSize!=null){this._size=+this.options.uploadSize;if(isNaN(this._size)){this._emitError(new Error("tus: cannot convert `uploadSize` option into a number"));return}}else{this._size=source.size;if(this._size==null){this._emitError(new Error("tus: cannot automatically derive upload's size from input and must be specified manually using the `uploadSize` option"));return}}var retryDelays=this.options.retryDelays;if(retryDelays!=null){if(Object.prototype.toString.call(retryDelays)!=="[object Array]"){this._emitError(new Error("tus: the `retryDelays` option must either be an array or null"));return}else{var errorCallback=this.options.onError;this.options.onError=function(err){_this2.options.onError=errorCallback;var shouldResetDelays=_this2._offset!=null&&_this2._offset>_this2._offsetBeforeRetry;if(shouldResetDelays){_this2._retryAttempt=0}var isOnline=true;if(typeof window!=="undefined"&&"navigator"in window&&window.navigator.onLine===false){isOnline=false}var status=err.originalRequest?err.originalRequest.status:0;var isServerError=!inStatusCategory(status,400)||status===409||status===423;var shouldRetry=_this2._retryAttempt<retryDelays.length&&err.originalRequest!=null&&isServerError&&isOnline;if(!shouldRetry){_this2._emitError(err);return}var delay=retryDelays[_this2._retryAttempt++];_this2._offsetBeforeRetry=_this2._offset;_this2.options.uploadUrl=_this2.url;_this2._retryTimeout=setTimeout(function(){_this2.start()},delay)}}}this._aborted=false;if(this.url!=null){this._resumeUpload();return}if(this.options.uploadUrl!=null){this.url=this.options.uploadUrl;this._resumeUpload();return}if(this._hasStorage()){this.options.fingerprint(file,this.options,function(err,fingerprintValue){if(err){_this2._emitError(err);return}_this2._fingerprint=fingerprintValue;_this2._storage.getItem(_this2._fingerprint,function(err,resumedUrl){if(err){_this2._emitError(err);return}if(resumedUrl!=null){_this2.url=resumedUrl;_this2._resumeUpload()}else{_this2._createUpload()}})})}else{this._createUpload()}}},{key:"abort",value:function abort(shouldTerminate,cb){var _this3=this;if(this._xhr!==null){this._xhr.abort();this._source.close()}this._aborted=true;if(this._retryTimeout!=null){clearTimeout(this._retryTimeout);this._retryTimeout=null}cb=cb||function(){};if(shouldTerminate){Upload.terminate(this.url,this.options,function(err,xhr){if(err){return cb(err,xhr)}_this3._hasStorage()?_this3._storage.removeItem(_this3._fingerprint,cb):cb()})}else{cb()}}},{key:"_hasStorage",value:function _hasStorage(){return this.options.resume&&this._storage}},{key:"_emitXhrError",value:function _emitXhrError(xhr,err,causingErr){this._emitError(new _error2.default(err,causingErr,xhr))}},{key:"_emitError",value:function _emitError(err){if(typeof this.options.onError==="function"){this.options.onError(err)}else{throw err}}},{key:"_emitSuccess",value:function _emitSuccess(){if(typeof this.options.onSuccess==="function"){this.options.onSuccess()}}},{key:"_emitProgress",value:function _emitProgress(bytesSent,bytesTotal){if(typeof this.options.onProgress==="function"){this.options.onProgress(bytesSent,bytesTotal)}}},{key:"_emitChunkComplete",value:function _emitChunkComplete(chunkSize,bytesAccepted,bytesTotal){if(typeof this.options.onChunkComplete==="function"){this.options.onChunkComplete(chunkSize,bytesAccepted,bytesTotal)}}},{key:"_setupXHR",value:function _setupXHR(xhr){this._xhr=xhr;setupXHR(xhr,this.options)}},{key:"_createUpload",value:function _createUpload(){var _this4=this;if(!this.options.endpoint){this._emitError(new Error("tus: unable to create upload because no endpoint is provided"));return}var xhr=(0,_request.newRequest)();xhr.open("POST",this.options.endpoint,true);xhr.onload=function(){if(!inStatusCategory(xhr.status,200)){_this4._emitXhrError(xhr,new Error("tus: unexpected response while creating upload"));return}var location=xhr.getResponseHeader("Location");if(location==null){_this4._emitXhrError(xhr,new Error("tus: invalid or missing Location header"));return}_this4.url=(0,_request.resolveUrl)(_this4.options.endpoint,location);if(_this4._size===0){_this4._emitSuccess();_this4._source.close();return}if(_this4._hasStorage()){_this4._storage.setItem(_this4._fingerprint,_this4.url,function(err){if(err){_this4._emitError(err)}})}if(_this4.options.uploadDataDuringCreation){_this4._handleUploadResponse(xhr)}else{_this4._offset=0;_this4._startUpload()}};xhr.onerror=function(err){_this4._emitXhrError(xhr,new Error("tus: failed to create upload"),err)};this._setupXHR(xhr);if(this.options.uploadLengthDeferred){xhr.setRequestHeader("Upload-Defer-Length",1)}else{xhr.setRequestHeader("Upload-Length",this._size)}var metadata=encodeMetadata(this.options.metadata);if(metadata!==""){xhr.setRequestHeader("Upload-Metadata",metadata)}if(this.options.uploadDataDuringCreation&&!this.options.uploadLengthDeferred){this._offset=0;this._addChunkToRequest(xhr)}else{xhr.send(null)}}},{key:"_resumeUpload",value:function _resumeUpload(){var _this5=this;var xhr=(0,_request.newRequest)();xhr.open("HEAD",this.url,true);xhr.onload=function(){if(!inStatusCategory(xhr.status,200)){if(_this5._hasStorage()&&inStatusCategory(xhr.status,400)){_this5._storage.removeItem(_this5._fingerprint,function(err){if(err){_this5._emitError(err)}})}if(xhr.status===423){_this5._emitXhrError(xhr,new Error("tus: upload is currently locked; retry later"));return}if(!_this5.options.endpoint){_this5._emitXhrError(xhr,new Error("tus: unable to resume upload (new upload cannot be created without an endpoint)"));return}_this5.url=null;_this5._createUpload();return}var offset=parseInt(xhr.getResponseHeader("Upload-Offset"),10);if(isNaN(offset)){_this5._emitXhrError(xhr,new Error("tus: invalid or missing offset value"));return}var length=parseInt(xhr.getResponseHeader("Upload-Length"),10);if(isNaN(length)&&!_this5.options.uploadLengthDeferred){_this5._emitXhrError(xhr,new Error("tus: invalid or missing length value"));return}if(offset===length){_this5._emitProgress(length,length);_this5._emitSuccess();return}_this5._offset=offset;_this5._startUpload()};xhr.onerror=function(err){_this5._emitXhrError(xhr,new Error("tus: failed to resume upload"),err)};this._setupXHR(xhr);xhr.send(null)}},{key:"_startUpload",value:function _startUpload(){var _this6=this;if(this._aborted){return}var xhr=(0,_request.newRequest)();if(this.options.overridePatchMethod){xhr.open("POST",this.url,true);xhr.setRequestHeader("X-HTTP-Method-Override","PATCH")}else{xhr.open("PATCH",this.url,true)}xhr.onload=function(){if(!inStatusCategory(xhr.status,200)){_this6._emitXhrError(xhr,new Error("tus: unexpected response while uploading chunk"));return}_this6._handleUploadResponse(xhr)};xhr.onerror=function(err){if(_this6._aborted){return}_this6._emitXhrError(xhr,new Error("tus: failed to upload chunk at offset "+_this6._offset),err)};this._setupXHR(xhr);xhr.setRequestHeader("Upload-Offset",this._offset);this._addChunkToRequest(xhr)}},{key:"_addChunkToRequest",value:function _addChunkToRequest(xhr){var _this7=this;if("upload"in xhr){xhr.upload.onprogress=function(e){if(!e.lengthComputable){return}_this7._emitProgress(start+e.loaded,_this7._size)}}xhr.setRequestHeader("Content-Type","application/offset+octet-stream");var start=this._offset;var end=this._offset+this.options.chunkSize;if((end===Infinity||end>this._size)&&!this.options.uploadLengthDeferred){end=this._size}this._source.slice(start,end,function(err,value,complete){if(err){_this7._emitError(err);return}if(_this7.options.uploadLengthDeferred){if(complete){_this7._size=_this7._offset+(value&&value.size?value.size:0);xhr.setRequestHeader("Upload-Length",_this7._size)}}if(value===null){xhr.send()}else{xhr.send(value);_this7._emitProgress(_this7._offset,_this7._size)}})}},{key:"_handleUploadResponse",value:function _handleUploadResponse(xhr){var _this8=this;var offset=parseInt(xhr.getResponseHeader("Upload-Offset"),10);if(isNaN(offset)){this._emitXhrError(xhr,new Error("tus: invalid or missing offset value"));return}this._emitProgress(offset,this._size);this._emitChunkComplete(offset-this._offset,offset,this._size);this._offset=offset;if(offset==this._size){if(this.options.removeFingerprintOnSuccess&&this.options.resume){this._storage.removeItem(this._fingerprint,function(err){if(err){_this8._emitError(err)}})}this._emitSuccess();this._source.close();return}this._startUpload()}}],[{key:"terminate",value:function terminate(url,options,cb){if(typeof options!=="function"&&typeof cb!=="function"){throw new Error("tus: a callback function must be specified")}if(typeof options==="function"){cb=options;options={}}var xhr=(0,_request.newRequest)();xhr.open("DELETE",url,true);xhr.onload=function(){if(xhr.status!==204){cb(new _error2.default(new Error("tus: unexpected response while terminating upload"),null,xhr));return}cb()};xhr.onerror=function(err){cb(new _error2.default(err,new Error("tus: failed to terminate upload"),xhr))};setupXHR(xhr,options);xhr.send(null)}}]);return Upload}();function encodeMetadata(metadata){var encoded=[];for(var key in metadata){encoded.push(key+" "+_jsBase.Base64.encode(metadata[key]))}return encoded.join(",")}function inStatusCategory(status,category){return status>=category&&status<category+100}function setupXHR(xhr,options){xhr.setRequestHeader("Tus-Resumable","1.0.0");var headers=options.headers||{};for(var name in headers){xhr.setRequestHeader(name,headers[name])}xhr.withCredentials=options.withCredentials}Upload.defaultOptions=defaultOptions;exports.default=Upload},{"./error":9,"./node/fingerprint":1,"./node/request":5,"./node/source":6,"./node/storage":7,extend:12,"js-base64":13}],12:[function(_dereq_,module,exports){"use strict";var hasOwn=Object.prototype.hasOwnProperty;var toStr=Object.prototype.toString;var defineProperty=Object.defineProperty;var gOPD=Object.getOwnPropertyDescriptor;var isArray=function isArray(arr){if(typeof Array.isArray==="function"){return Array.isArray(arr)}return toStr.call(arr)==="[object Array]"};var isPlainObject=function isPlainObject(obj){if(!obj||toStr.call(obj)!=="[object Object]"){return false}var hasOwnConstructor=hasOwn.call(obj,"constructor");var hasIsPrototypeOf=obj.constructor&&obj.constructor.prototype&&hasOwn.call(obj.constructor.prototype,"isPrototypeOf");if(obj.constructor&&!hasOwnConstructor&&!hasIsPrototypeOf){return false}var key;for(key in obj){}return typeof key==="undefined"||hasOwn.call(obj,key)};var setProperty=function setProperty(target,options){if(defineProperty&&options.name==="__proto__"){defineProperty(target,options.name,{enumerable:true,configurable:true,value:options.newValue,writable:true})}else{target[options.name]=options.newValue}};var getProperty=function getProperty(obj,name){if(name==="__proto__"){if(!hasOwn.call(obj,name)){return void 0}else if(gOPD){return gOPD(obj,name).value}}return obj[name]};module.exports=function extend(){var options,name,src,copy,copyIsArray,clone;var target=arguments[0];var i=1;var length=arguments.length;var deep=false;if(typeof target==="boolean"){deep=target;target=arguments[1]||{};i=2}if(target==null||typeof target!=="object"&&typeof target!=="function"){target={}}for(;i<length;++i){options=arguments[i];if(options!=null){for(name in options){src=getProperty(target,name);copy=getProperty(options,name);if(target!==copy){if(deep&&copy&&(isPlainObject(copy)||(copyIsArray=isArray(copy)))){if(copyIsArray){copyIsArray=false;clone=src&&isArray(src)?src:[]}else{clone=src&&isPlainObject(src)?src:{}}setProperty(target,{name:name,newValue:extend(deep,clone,copy)})}else if(typeof copy!=="undefined"){setProperty(target,{name:name,newValue:copy})}}}}}return target}},{}],13:[function(_dereq_,module,exports){(function(global){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory(global):typeof define==="function"&&define.amd?define(factory):factory(global)})(typeof self!=="undefined"?self:typeof window!=="undefined"?window:typeof global!=="undefined"?global:this,function(global){"use strict";var _Base64=global.Base64;var version="2.4.9";var buffer;if(typeof module!=="undefined"&&module.exports){try{buffer=eval("require('buffer').Buffer")}catch(err){buffer=undefined}}var b64chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var b64tab=function(bin){var t={};for(var i=0,l=bin.length;i<l;i++)t[bin.charAt(i)]=i;return t}(b64chars);var fromCharCode=String.fromCharCode;var cb_utob=function(c){if(c.length<2){var cc=c.charCodeAt(0);return cc<128?c:cc<2048?fromCharCode(192|cc>>>6)+fromCharCode(128|cc&63):fromCharCode(224|cc>>>12&15)+fromCharCode(128|cc>>>6&63)+fromCharCode(128|cc&63)}else{var cc=65536+(c.charCodeAt(0)-55296)*1024+(c.charCodeAt(1)-56320);return fromCharCode(240|cc>>>18&7)+fromCharCode(128|cc>>>12&63)+fromCharCode(128|cc>>>6&63)+fromCharCode(128|cc&63)}};var re_utob=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;var utob=function(u){return u.replace(re_utob,cb_utob)};var cb_encode=function(ccc){var padlen=[0,2,1][ccc.length%3],ord=ccc.charCodeAt(0)<<16|(ccc.length>1?ccc.charCodeAt(1):0)<<8|(ccc.length>2?ccc.charCodeAt(2):0),chars=[b64chars.charAt(ord>>>18),b64chars.charAt(ord>>>12&63),padlen>=2?"=":b64chars.charAt(ord>>>6&63),padlen>=1?"=":b64chars.charAt(ord&63)];return chars.join("")};var btoa=global.btoa?function(b){return global.btoa(b)}:function(b){return b.replace(/[\s\S]{1,3}/g,cb_encode)};var _encode=buffer?buffer.from&&Uint8Array&&buffer.from!==Uint8Array.from?function(u){return(u.constructor===buffer.constructor?u:buffer.from(u)).toString("base64")}:function(u){return(u.constructor===buffer.constructor?u:new buffer(u)).toString("base64")}:function(u){return btoa(utob(u))};var encode=function(u,urisafe){return!urisafe?_encode(String(u)):_encode(String(u)).replace(/[+\/]/g,function(m0){return m0=="+"?"-":"_"}).replace(/=/g,"")};var encodeURI=function(u){return encode(u,true)};var re_btou=new RegExp(["[À-ß][€-¿]","[à-ï][€-¿]{2}","[ð-÷][€-¿]{3}"].join("|"),"g");var cb_btou=function(cccc){switch(cccc.length){case 4:var cp=(7&cccc.charCodeAt(0))<<18|(63&cccc.charCodeAt(1))<<12|(63&cccc.charCodeAt(2))<<6|63&cccc.charCodeAt(3),offset=cp-65536;return fromCharCode((offset>>>10)+55296)+fromCharCode((offset&1023)+56320);case 3:return fromCharCode((15&cccc.charCodeAt(0))<<12|(63&cccc.charCodeAt(1))<<6|63&cccc.charCodeAt(2));default:return fromCharCode((31&cccc.charCodeAt(0))<<6|63&cccc.charCodeAt(1))}};var btou=function(b){return b.replace(re_btou,cb_btou)};var cb_decode=function(cccc){var len=cccc.length,padlen=len%4,n=(len>0?b64tab[cccc.charAt(0)]<<18:0)|(len>1?b64tab[cccc.charAt(1)]<<12:0)|(len>2?b64tab[cccc.charAt(2)]<<6:0)|(len>3?b64tab[cccc.charAt(3)]:0),chars=[fromCharCode(n>>>16),fromCharCode(n>>>8&255),fromCharCode(n&255)];chars.length-=[0,0,2,1][padlen];return chars.join("")};var atob=global.atob?function(a){return global.atob(a)}:function(a){return a.replace(/[\s\S]{1,4}/g,cb_decode)};var _decode=buffer?buffer.from&&Uint8Array&&buffer.from!==Uint8Array.from?function(a){return(a.constructor===buffer.constructor?a:buffer.from(a,"base64")).toString()}:function(a){return(a.constructor===buffer.constructor?a:new buffer(a,"base64")).toString()}:function(a){return btou(atob(a))};var decode=function(a){return _decode(String(a).replace(/[-_]/g,function(m0){return m0=="-"?"+":"/"}).replace(/[^A-Za-z0-9\+\/]/g,""))};var noConflict=function(){var Base64=global.Base64;global.Base64=_Base64;return Base64};global.Base64={VERSION:version,atob:atob,btoa:btoa,fromBase64:decode,toBase64:encode,utob:utob,encode:encode,encodeURI:encodeURI,btou:btou,decode:decode,noConflict:noConflict,__buffer__:buffer};if(typeof Object.defineProperty==="function"){var noEnum=function(v){return{value:v,enumerable:false,writable:true,configurable:true}};global.Base64.extendString=function(){Object.defineProperty(String.prototype,"fromBase64",noEnum(function(){return decode(this)}));Object.defineProperty(String.prototype,"toBase64",noEnum(function(urisafe){return encode(this,urisafe)}));Object.defineProperty(String.prototype,"toBase64URI",noEnum(function(){return encode(this,true)}))}}if(global["Meteor"]){Base64=global.Base64}if(typeof module!=="undefined"&&module.exports){module.exports.Base64=global.Base64}else if(typeof define==="function"&&define.amd){define([],function(){return global.Base64})}return{Base64:global.Base64}})}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],14:[function(_dereq_,module,exports){"use strict";var has=Object.prototype.hasOwnProperty;function decode(input){return decodeURIComponent(input.replace(/\+/g," "))}function querystring(query){var parser=/([^=?&]+)=?([^&]*)/g,result={},part;while(part=parser.exec(query)){var key=decode(part[1]),value=decode(part[2]);
if(key in result)continue;result[key]=value}return result}function querystringify(obj,prefix){prefix=prefix||"";var pairs=[];if("string"!==typeof prefix)prefix="?";for(var key in obj){if(has.call(obj,key)){pairs.push(encodeURIComponent(key)+"="+encodeURIComponent(obj[key]))}}return pairs.length?prefix+pairs.join("&"):""}exports.stringify=querystringify;exports.parse=querystring},{}],15:[function(_dereq_,module,exports){"use strict";module.exports=function required(port,protocol){protocol=protocol.split(":")[0];port=+port;if(!port)return false;switch(protocol){case"http":case"ws":return port!==80;case"https":case"wss":return port!==443;case"ftp":return port!==21;case"gopher":return port!==70;case"file":return false}return port!==0}},{}],16:[function(_dereq_,module,exports){(function(global){"use strict";var required=_dereq_("requires-port"),qs=_dereq_("querystringify"),protocolre=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i,slashes=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//;var rules=[["#","hash"],["?","query"],function sanitize(address){return address.replace("\\","/")},["/","pathname"],["@","auth",1],[NaN,"host",undefined,1,1],[/:(\d+)$/,"port",undefined,1],[NaN,"hostname",undefined,1,1]];var ignore={hash:1,query:1};function lolcation(loc){var location=global&&global.location||{};loc=loc||location;var finaldestination={},type=typeof loc,key;if("blob:"===loc.protocol){finaldestination=new Url(unescape(loc.pathname),{})}else if("string"===type){finaldestination=new Url(loc,{});for(key in ignore)delete finaldestination[key]}else if("object"===type){for(key in loc){if(key in ignore)continue;finaldestination[key]=loc[key]}if(finaldestination.slashes===undefined){finaldestination.slashes=slashes.test(loc.href)}}return finaldestination}function extractProtocol(address){var match=protocolre.exec(address);return{protocol:match[1]?match[1].toLowerCase():"",slashes:!!match[2],rest:match[3]}}function resolve(relative,base){var path=(base||"/").split("/").slice(0,-1).concat(relative.split("/")),i=path.length,last=path[i-1],unshift=false,up=0;while(i--){if(path[i]==="."){path.splice(i,1)}else if(path[i]===".."){path.splice(i,1);up++}else if(up){if(i===0)unshift=true;path.splice(i,1);up--}}if(unshift)path.unshift("");if(last==="."||last==="..")path.push("");return path.join("/")}function Url(address,location,parser){if(!(this instanceof Url)){return new Url(address,location,parser)}var relative,extracted,parse,instruction,index,key,instructions=rules.slice(),type=typeof location,url=this,i=0;if("object"!==type&&"string"!==type){parser=location;location=null}if(parser&&"function"!==typeof parser)parser=qs.parse;location=lolcation(location);extracted=extractProtocol(address||"");relative=!extracted.protocol&&!extracted.slashes;url.slashes=extracted.slashes||relative&&location.slashes;url.protocol=extracted.protocol||location.protocol||"";address=extracted.rest;if(!extracted.slashes)instructions[3]=[/(.*)/,"pathname"];for(;i<instructions.length;i++){instruction=instructions[i];if(typeof instruction==="function"){address=instruction(address);continue}parse=instruction[0];key=instruction[1];if(parse!==parse){url[key]=address}else if("string"===typeof parse){if(~(index=address.indexOf(parse))){if("number"===typeof instruction[2]){url[key]=address.slice(0,index);address=address.slice(index+instruction[2])}else{url[key]=address.slice(index);address=address.slice(0,index)}}}else if(index=parse.exec(address)){url[key]=index[1];address=address.slice(0,index.index)}url[key]=url[key]||(relative&&instruction[3]?location[key]||"":"");if(instruction[4])url[key]=url[key].toLowerCase()}if(parser)url.query=parser(url.query);if(relative&&location.slashes&&url.pathname.charAt(0)!=="/"&&(url.pathname!==""||location.pathname!=="")){url.pathname=resolve(url.pathname,location.pathname)}if(!required(url.port,url.protocol)){url.host=url.hostname;url.port=""}url.username=url.password="";if(url.auth){instruction=url.auth.split(":");url.username=instruction[0]||"";url.password=instruction[1]||""}url.origin=url.protocol&&url.host&&url.protocol!=="file:"?url.protocol+"//"+url.host:"null";url.href=url.toString()}function set(part,value,fn){var url=this;switch(part){case"query":if("string"===typeof value&&value.length){value=(fn||qs.parse)(value)}url[part]=value;break;case"port":url[part]=value;if(!required(value,url.protocol)){url.host=url.hostname;url[part]=""}else if(value){url.host=url.hostname+":"+value}break;case"hostname":url[part]=value;if(url.port)value+=":"+url.port;url.host=value;break;case"host":url[part]=value;if(/:\d+$/.test(value)){value=value.split(":");url.port=value.pop();url.hostname=value.join(":")}else{url.hostname=value;url.port=""}break;case"protocol":url.protocol=value.toLowerCase();url.slashes=!fn;break;case"pathname":case"hash":if(value){var char=part==="pathname"?"/":"#";url[part]=value.charAt(0)!==char?char+value:value}else{url[part]=value}break;default:url[part]=value}for(var i=0;i<rules.length;i++){var ins=rules[i];if(ins[4])url[ins[1]]=url[ins[1]].toLowerCase()}url.origin=url.protocol&&url.host&&url.protocol!=="file:"?url.protocol+"//"+url.host:"null";url.href=url.toString();return url}function toString(stringify){if(!stringify||"function"!==typeof stringify)stringify=qs.stringify;var query,url=this,protocol=url.protocol;if(protocol&&protocol.charAt(protocol.length-1)!==":")protocol+=":";var result=protocol+(url.slashes?"//":"");if(url.username){result+=url.username;if(url.password)result+=":"+url.password;result+="@"}result+=url.host+url.pathname;query="object"===typeof url.query?stringify(url.query):url.query;if(query)result+="?"!==query.charAt(0)?"?"+query:query;if(url.hash)result+=url.hash;return result}Url.prototype={set:set,toString:toString};Url.extractProtocol=extractProtocol;Url.location=lolcation;Url.qs=qs;module.exports=Url}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{querystringify:14,"requires-port":15}]},{},[10])(10)});
//# sourceMappingURL=tus.min.js.map
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "profile-manager",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"blueimp-canvas-to-blob": {
"version": "3.17.0",
"resolved": "https://registry.npmjs.org/blueimp-canvas-to-blob/-/blueimp-canvas-to-blob-3.17.0.tgz",
"integrity": "sha512-LcuVZZtKtE4yUrLb0IQA7ndMm19gooDTrzvjjkvmQ1MhkFlSzTw+8Ftp+/ckfGeP2UDQvDsPyy8mIT69itAqbg==",
"optional": true
},
"blueimp-file-upload": {
"version": "10.7.0",
"resolved": "https://registry.npmjs.org/blueimp-file-upload/-/blueimp-file-upload-10.7.0.tgz",
"integrity": "sha512-mzJdtePtnKasTOwrgBB3lRsN33UnVg/N5VV2An0b6acF80+ooiH6IvbR8oQJMl7niyKuYyUUZSk7bTJ1TKUiCQ==",
"requires": {
"blueimp-canvas-to-blob": "3",
"blueimp-load-image": "2",
"blueimp-tmpl": "3"
}
},
"blueimp-load-image": {
"version": "2.26.0",
"resolved": "https://registry.npmjs.org/blueimp-load-image/-/blueimp-load-image-2.26.0.tgz",
"integrity": "sha512-pL7SYdK9ZxBFmFiEoh91PIYccU9IzytQ8goIUgc+5RW6vYVyvpGRUltefceeoNyLARbF8QXiYimHp6kgjZ/IBg==",
"optional": true
},
"blueimp-tmpl": {
"version": "3.13.0",
"resolved": "https://registry.npmjs.org/blueimp-tmpl/-/blueimp-tmpl-3.13.0.tgz",
"integrity": "sha512-TC5eLXhPGGgBJG1gGxKRORB5DMxSVSTS/GsqsQuJ+shv0Ez5wc9bjoXVhPqtdbzVZAzFvveasAMrjqEYY/18Og==",
"optional": true
},
"buffer-from": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-0.1.2.tgz",
"integrity": "sha512-RiWIenusJsmI2KcvqQABB83tLxCByE3upSP8QU3rJDMVFGPWLvPQJt/O1Su9moRWeH7d+Q2HYb68f6+v+tw2vg=="
},
"combine-errors": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/combine-errors/-/combine-errors-3.0.3.tgz",
"integrity": "sha1-9N9nQAg+VwOjGBEQwrEFUfAD2oY=",
"requires": {
"custom-error-instance": "2.1.1",
"lodash.uniqby": "4.5.0"
}
},
"custom-error-instance": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/custom-error-instance/-/custom-error-instance-2.1.1.tgz",
"integrity": "sha1-PPY5FIemYppiR+sMoM4ACBt+Nho="
},
"extend": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
"integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="
},
"fine-uploader": {
"version": "5.16.2",
"resolved": "https://registry.npmjs.org/fine-uploader/-/fine-uploader-5.16.2.tgz",
"integrity": "sha1-DYeNoc0nU/gGg6wJHfXa/5/7jEQ="
},
"graceful-fs": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz",
"integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ=="
},
"js-base64": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.5.1.tgz",
"integrity": "sha512-M7kLczedRMYX4L8Mdh4MzyAMM9O5osx+4FcOQuTvr3A9F2D9S5JXheN0ewNbrvK2UatkTRhL5ejGmGSjNMiZuw=="
},
"lodash._baseiteratee": {
"version": "4.7.0",
"resolved": "https://registry.npmjs.org/lodash._baseiteratee/-/lodash._baseiteratee-4.7.0.tgz",
"integrity": "sha1-NKm1VDVycnw9sueO2uPA6eZr0QI=",
"requires": {
"lodash._stringtopath": "~4.8.0"
}
},
"lodash._basetostring": {
"version": "4.12.0",
"resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-4.12.0.tgz",
"integrity": "sha1-kyfJ3FFYhmt/pLnUL0Y45XZt2d8="
},
"lodash._baseuniq": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz",
"integrity": "sha1-DrtE5FaBSveQXGIS+iybLVG4Qeg=",
"requires": {
"lodash._createset": "~4.0.0",
"lodash._root": "~3.0.0"
}
},
"lodash._createset": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/lodash._createset/-/lodash._createset-4.0.3.tgz",
"integrity": "sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY="
},
"lodash._root": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/lodash._root/-/lodash._root-3.0.1.tgz",
"integrity": "sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI="
},
"lodash._stringtopath": {
"version": "4.8.0",
"resolved": "https://registry.npmjs.org/lodash._stringtopath/-/lodash._stringtopath-4.8.0.tgz",
"integrity": "sha1-lBvPDmQmbl/B1m/tCmlZVExXaCQ=",
"requires": {
"lodash._basetostring": "~4.12.0"
}
},
"lodash.throttle": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz",
"integrity": "sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ="
},
"lodash.uniqby": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.uniqby/-/lodash.uniqby-4.5.0.tgz",
"integrity": "sha1-o6F7v2LutiQPSRhG6XwcTipeHiE=",
"requires": {
"lodash._baseiteratee": "~4.7.0",
"lodash._baseuniq": "~4.6.0"
}
},
"proper-lockfile": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/proper-lockfile/-/proper-lockfile-2.0.1.tgz",
"integrity": "sha1-FZ+wYZPTIAP0s2kd0uwaY0qoDR0=",
"requires": {
"graceful-fs": "^4.1.2",
"retry": "^0.10.0"
}
},
"querystringify": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.1.tgz",
"integrity": "sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA=="
},
"requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
},
"retry": {
"version": "0.10.1",
"resolved": "https://registry.npmjs.org/retry/-/retry-0.10.1.tgz",
"integrity": "sha1-52OI0heZLCUnUCQdPTlW/tmNj/Q="
},
"tus-js-client": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/tus-js-client/-/tus-js-client-1.8.0.tgz",
"integrity": "sha512-qPX3TywqzxocTxUZtcS8X7Aik72SVMa0jKi4hWyfvRV+s9raVzzYGaP4MoJGaF0yOgm2+b6jXaVEHogxcJ8LGw==",
"requires": {
"buffer-from": "^0.1.1",
"combine-errors": "^3.0.3",
"extend": "^3.0.2",
"js-base64": "^2.4.9",
"lodash.throttle": "^4.1.1",
"proper-lockfile": "^2.0.1",
"url-parse": "^1.4.3"
}
},
"url-parse": {
"version": "1.4.7",
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz",
"integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==",
"requires": {
"querystringify": "^2.1.1",
"requires-port": "^1.0.0"
}
}
}
}
{
"name": "profile-manager",
"version": "1.0.0",
"dependencies": {
"blueimp-file-upload": "^10.7.0",
"fine-uploader": "^5.16.2",
"tus-js-client": "^1.8.0"
}
}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Tus File Upload Sample</title>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous">
</script>
<script src="dist/tus.js"></script>
</head>
<body>
<div>
<form>
<div>
<h3>Upload process will be started immediately after you choose a file.</h4>
<h5>You can see the progress on browser's console</h6>
<input type="file">
</div>
</form>
</div>
<script>
$(document).ready(function () {
$('input[type="file"]').change(function (e) {
let file = e.target.files[0]
let channelId = "9708bdf6-a4a1-4807-a212-f6c994d7d975";
let authorization = "Apikey a8c3c9f1-4313-43ef-a4b0-fbd343b21302";
let options = {
"url": `https://napi.arvancloud.com/vod/2.0/channels/${channelId}/files`,
"authorization": `${authorization}`,
"acceptLanguage": "en",
"uuid": file.name + file.size + file.lastModified
}
let upload = new tus.Upload(file, {
fingerprint: () => {
return options.uuid
},
resume: true,
chunkSize: 1048576, // 1MB
endpoint: options.url,
retryDelays: [0, 500, 1000, 1500, 2000, 2500],
headers: {
'Authorization': options.authorization,
'Accept-Language': options.acceptLanguage
},
metadata: {
filename: file.name,
filetype: file.type
},
onError: function (error) {
console.log("Failed because: " + error)
},
onProgress: function (bytesUploaded, bytesTotal) {
var percentage = (bytesUploaded / bytesTotal * 100).toFixed(2)
console.log(bytesUploaded, bytesTotal, percentage + "%")
},
onSuccess: function () {
console.log("Download %s from %s", upload.file.name, upload.url)
}
});
upload.start()
});
});
</script>
</body>
</html>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
<!DOCTYPE>
<html lang="fa">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
</head>
<body>
<form id="myForm" action="upload.php" method="post">
<input type="file" name="myfile">
<input type="submit" value="Submit"/>
</form>
<div class="progress">
<div class="bar"></div>
<div class="percent">0%</div>
</div>
<h2>HTML5 File Upload Progress Bar Tutorial</h2>
<form id="upload_form" enctype="multipart/form-data" method="post">
<input type="file" name="myfile" id="file1" onchange="uploadFile()"><br>
<progress id="progressBar" value="0" max="100" style="width:300px;"></progress>
<h3 id="status"></h3>
<h3 id="type"></h3>
<p id="loaded_n_total"></p>
</form>
<script>
function _(el) {
return document.getElementById(el);
}
function getExtension(filename) {
var parts = filename.split('.');
return parts[parts.length - 1];
}
function isVideo(filename) {
var ext = getExtension(filename);
switch (ext.toLowerCase()) {
case 'm4v':
case 'avi':
case 'mpg':
case 'mp4':
return true;
}
return false;
}
function uploadFile() {
var file = _("file1").files[0];
// alert(file.name+" | "+file.size+" | "+file.type);
var error="";
if(file.size>=100000000){
error+="حجم فایل نامناسب است"
}
if(!isVideo(file.name)){
error+="نوع فایل باید ویدیو باشد."
}
if(error!==""){
_("status").innerHTML=error;
}else{
var formdata = new FormData();
formdata.append("myfile", file);
var ajax = new XMLHttpRequest();
ajax.upload.addEventListener("progress", progressHandler, false);
ajax.addEventListener("load", completeHandler, false);
ajax.addEventListener("error", errorHandler, false);
ajax.addEventListener("abort", abortHandler, false);
ajax.open("POST", "upload.php"); // http://www.developphp.com/video/JavaScript/File-Upload-Progress-Bar-Meter-Tutorial-Ajax-PHP
//use file_upload_parser.php from above url
ajax.send(formdata);
}
}
function progressHandler(event) {
_("loaded_n_total").innerHTML = "Uploaded " + event.loaded + " bytes of " + event.total;
var percent = (event.loaded / event.total) * 100;
_("progressBar").value = Math.round(percent);
_("status").innerHTML = Math.round(percent) + "% uploaded... please wait";
}
function completeHandler(event) {
_("status").innerHTML = event.target.responseText;
_("progressBar").value = 0; //wil clear progress bar after successful upload
_("progressBar").style.display="none";
}
function errorHandler(event) {
_("status").innerHTML = "Upload Failed";
}
function abortHandler(event) {
_("status").innerHTML = "Upload Aborted";
}
</script>
</body>
</html>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
/*!
* jQuery Form Plugin
* version: 4.2.2
* Requires jQuery v1.7.2 or later
* Project repository: https://github.com/jquery-form/form
* Copyright 2017 Kevin Morris
* Copyright 2006 M. Alsup
* Dual licensed under the LGPL-2.1+ or MIT licenses
* https://github.com/jquery-form/form#license
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
/* global ActiveXObject */
/* eslint-disable */
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if (typeof module === 'object' && module.exports) {
// Node/CommonJS
module.exports = function( root, jQuery ) {
if (typeof jQuery === 'undefined') {
// require('jQuery') returns a factory that requires window to build a jQuery instance, we normalize how we use modules
// that require this pattern but the window provided is a noop if it's defined (how jquery works)
if (typeof window !== 'undefined') {
jQuery = require('jquery');
}
else {
jQuery = require('jquery')(root);
}
}
factory(jQuery);
return jQuery;
};
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
/* eslint-enable */
'use strict';
/*
Usage Note:
-----------
Do not use both ajaxSubmit and ajaxForm on the same form. These
functions are mutually exclusive. Use ajaxSubmit if you want
to bind your own submit handler to the form. For example,
$(document).ready(function() {
$('#myForm').on('submit', function(e) {
e.preventDefault(); // <-- important
$(this).ajaxSubmit({
target: '#output'
});
});
});
Use ajaxForm when you want the plugin to manage all the event binding
for you. For example,
$(document).ready(function() {
$('#myForm').ajaxForm({
target: '#output'
});
});
You can also use ajaxForm with delegation (requires jQuery v1.7+), so the
form does not have to exist when you invoke ajaxForm:
$('#myForm').ajaxForm({
delegation: true,
target: '#output'
});
When using ajaxForm, the ajaxSubmit function will be invoked for you
at the appropriate time.
*/
var rCRLF = /\r?\n/g;
/**
* Feature detection
*/
var feature = {};
feature.fileapi = $('<input type="file">').get(0).files !== undefined;
feature.formdata = (typeof window.FormData !== 'undefined');
var hasProp = !!$.fn.prop;
// attr2 uses prop when it can but checks the return type for
// an expected string. This accounts for the case where a form
// contains inputs with names like "action" or "method"; in those
// cases "prop" returns the element
$.fn.attr2 = function() {
if (!hasProp) {
return this.attr.apply(this, arguments);
}
var val = this.prop.apply(this, arguments);
if ((val && val.jquery) || typeof val === 'string') {
return val;
}
return this.attr.apply(this, arguments);
};
/**
* ajaxSubmit() provides a mechanism for immediately submitting
* an HTML form using AJAX.
*
* @param {object|string} options jquery.form.js parameters or custom url for submission
* @param {object} data extraData
* @param {string} dataType ajax dataType
* @param {function} onSuccess ajax success callback function
*/
$.fn.ajaxSubmit = function(options, data, dataType, onSuccess) {
// fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
if (!this.length) {
log('ajaxSubmit: skipping submit process - no element selected');
return this;
}
/* eslint consistent-this: ["error", "$form"] */
var method, action, url, $form = this;
if (typeof options === 'function') {
options = {success: options};
} else if (typeof options === 'string' || (options === false && arguments.length > 0)) {
options = {
'url' : options,
'data' : data,
'dataType' : dataType
};
if (typeof onSuccess === 'function') {
options.success = onSuccess;
}
} else if (typeof options === 'undefined') {
options = {};
}
method = options.method || options.type || this.attr2('method');
action = options.url || this.attr2('action');
url = (typeof action === 'string') ? $.trim(action) : '';
url = url || window.location.href || '';
if (url) {
// clean url (don't include hash vaue)
url = (url.match(/^([^#]+)/) || [])[1];
}
options = $.extend(true, {
url : url,
success : $.ajaxSettings.success,
type : method || $.ajaxSettings.type,
iframeSrc : /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' // eslint-disable-line no-script-url
}, options);
// hook for manipulating the form data before it is extracted;
// convenient for use with rich editors like tinyMCE or FCKEditor
var veto = {};
this.trigger('form-pre-serialize', [this, options, veto]);
if (veto.veto) {
log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
return this;
}
// provide opportunity to alter form data before it is serialized
if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
log('ajaxSubmit: submit aborted via beforeSerialize callback');
return this;
}
var traditional = options.traditional;
if (typeof traditional === 'undefined') {
traditional = $.ajaxSettings.traditional;
}
var elements = [];
var qx, a = this.formToArray(options.semantic, elements, options.filtering);
if (options.data) {
var optionsData = $.isFunction(options.data) ? options.data(a) : options.data;
options.extraData = optionsData;
qx = $.param(optionsData, traditional);
}
// give pre-submit callback an opportunity to abort the submit
if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
log('ajaxSubmit: submit aborted via beforeSubmit callback');
return this;
}
// fire vetoable 'validate' event
this.trigger('form-submit-validate', [a, this, options, veto]);
if (veto.veto) {
log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
return this;
}
var q = $.param(a, traditional);
if (qx) {
q = (q ? (q + '&' + qx) : qx);
}
if (options.type.toUpperCase() === 'GET') {
options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
options.data = null; // data is null for 'get'
} else {
options.data = q; // data is the query string for 'post'
}
var callbacks = [];
if (options.resetForm) {
callbacks.push(function() {
$form.resetForm();
});
}
if (options.clearForm) {
callbacks.push(function() {
$form.clearForm(options.includeHidden);
});
}
// perform a load on the target only if dataType is not provided
if (!options.dataType && options.target) {
var oldSuccess = options.success || function(){};
callbacks.push(function(data, textStatus, jqXHR) {
var successArguments = arguments,
fn = options.replaceTarget ? 'replaceWith' : 'html';
$(options.target)[fn](data).each(function(){
oldSuccess.apply(this, successArguments);
});
});
} else if (options.success) {
if ($.isArray(options.success)) {
$.merge(callbacks, options.success);
} else {
callbacks.push(options.success);
}
}
options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
var context = options.context || this; // jQuery 1.4+ supports scope context
for (var i = 0, max = callbacks.length; i < max; i++) {
callbacks[i].apply(context, [data, status, xhr || $form, $form]);
}
};
if (options.error) {
var oldError = options.error;
options.error = function(xhr, status, error) {
var context = options.context || this;
oldError.apply(context, [xhr, status, error, $form]);
};
}
if (options.complete) {
var oldComplete = options.complete;
options.complete = function(xhr, status) {
var context = options.context || this;
oldComplete.apply(context, [xhr, status, $form]);
};
}
// are there files to upload?
// [value] (issue #113), also see comment:
// https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219
var fileInputs = $('input[type=file]:enabled', this).filter(function() {
return $(this).val() !== '';
});
var hasFileInputs = fileInputs.length > 0;
var mp = 'multipart/form-data';
var multipart = ($form.attr('enctype') === mp || $form.attr('encoding') === mp);
var fileAPI = feature.fileapi && feature.formdata;
log('fileAPI :' + fileAPI);
var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI;
var jqxhr;
// options.iframe allows user to force iframe mode
// 06-NOV-09: now defaulting to iframe mode if file input is detected
if (options.iframe !== false && (options.iframe || shouldUseFrame)) {
// hack to fix Safari hang (thanks to Tim Molendijk for this)
// see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
if (options.closeKeepAlive) {
$.get(options.closeKeepAlive, function() {
jqxhr = fileUploadIframe(a);
});
} else {
jqxhr = fileUploadIframe(a);
}
} else if ((hasFileInputs || multipart) && fileAPI) {
jqxhr = fileUploadXhr(a);
} else {
jqxhr = $.ajax(options);
}
$form.removeData('jqxhr').data('jqxhr', jqxhr);
// clear element array
for (var k = 0; k < elements.length; k++) {
elements[k] = null;
}
// fire 'notify' event
this.trigger('form-submit-notify', [this, options]);
return this;
// utility fn for deep serialization
function deepSerialize(extraData) {
var serialized = $.param(extraData, options.traditional).split('&');
var len = serialized.length;
var result = [];
var i, part;
for (i = 0; i < len; i++) {
// #252; undo param space replacement
serialized[i] = serialized[i].replace(/\+/g, ' ');
part = serialized[i].split('=');
// #278; use array instead of object storage, favoring array serializations
result.push([decodeURIComponent(part[0]), decodeURIComponent(part[1])]);
}
return result;
}
// XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz)
function fileUploadXhr(a) {
var formdata = new FormData();
for (var i = 0; i < a.length; i++) {
formdata.append(a[i].name, a[i].value);
}
if (options.extraData) {
var serializedData = deepSerialize(options.extraData);
for (i = 0; i < serializedData.length; i++) {
if (serializedData[i]) {
formdata.append(serializedData[i][0], serializedData[i][1]);
}
}
}
options.data = null;
var s = $.extend(true, {}, $.ajaxSettings, options, {
contentType : false,
processData : false,
cache : false,
type : method || 'POST'
});
if (options.uploadProgress) {
// workaround because jqXHR does not expose upload property
s.xhr = function() {
var xhr = $.ajaxSettings.xhr();
if (xhr.upload) {
xhr.upload.addEventListener('progress', function(event) {
var percent = 0;
var position = event.loaded || event.position; /* event.position is deprecated */
var total = event.total;
if (event.lengthComputable) {
percent = Math.ceil(position / total * 100);
}
options.uploadProgress(event, position, total, percent);
}, false);
}
return xhr;
};
}
s.data = null;
var beforeSend = s.beforeSend;
s.beforeSend = function(xhr, o) {
// Send FormData() provided by user
if (options.formData) {
o.data = options.formData;
} else {
o.data = formdata;
}
if (beforeSend) {
beforeSend.call(this, xhr, o);
}
};
return $.ajax(s);
}
// private function for handling file uploads (hat tip to YAHOO!)
function fileUploadIframe(a) {
var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle;
var deferred = $.Deferred();
// #341
deferred.abort = function(status) {
xhr.abort(status);
};
if (a) {
// ensure that every serialized input is still enabled
for (i = 0; i < elements.length; i++) {
el = $(elements[i]);
if (hasProp) {
el.prop('disabled', false);
} else {
el.removeAttr('disabled');
}
}
}
s = $.extend(true, {}, $.ajaxSettings, options);
s.context = s.context || s;
id = 'jqFormIO' + new Date().getTime();
var ownerDocument = form.ownerDocument;
var $body = $form.closest('body');
if (s.iframeTarget) {
$io = $(s.iframeTarget, ownerDocument);
n = $io.attr2('name');
if (!n) {
$io.attr2('name', id);
} else {
id = n;
}
} else {
$io = $('<iframe name="' + id + '" src="' + s.iframeSrc + '" />', ownerDocument);
$io.css({position: 'absolute', top: '-1000px', left: '-1000px'});
}
io = $io[0];
xhr = { // mock object
aborted : 0,
responseText : null,
responseXML : null,
status : 0,
statusText : 'n/a',
getAllResponseHeaders : function() {},
getResponseHeader : function() {},
setRequestHeader : function() {},
abort : function(status) {
var e = (status === 'timeout' ? 'timeout' : 'aborted');
log('aborting upload... ' + e);
this.aborted = 1;
try { // #214, #257
if (io.contentWindow.document.execCommand) {
io.contentWindow.document.execCommand('Stop');
}
} catch (ignore) {}
$io.attr('src', s.iframeSrc); // abort op in progress
xhr.error = e;
if (s.error) {
s.error.call(s.context, xhr, e, status);
}
if (g) {
$.event.trigger('ajaxError', [xhr, s, e]);
}
if (s.complete) {
s.complete.call(s.context, xhr, e);
}
}
};
g = s.global;
// trigger ajax global events so that activity/block indicators work like normal
if (g && $.active++ === 0) {
$.event.trigger('ajaxStart');
}
if (g) {
$.event.trigger('ajaxSend', [xhr, s]);
}
if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
if (s.global) {
$.active--;
}
deferred.reject();
return deferred;
}
if (xhr.aborted) {
deferred.reject();
return deferred;
}
// add submitting element to data if we know it
sub = form.clk;
if (sub) {
n = sub.name;
if (n && !sub.disabled) {
s.extraData = s.extraData || {};
s.extraData[n] = sub.value;
if (sub.type === 'image') {
s.extraData[n + '.x'] = form.clk_x;
s.extraData[n + '.y'] = form.clk_y;
}
}
}
var CLIENT_TIMEOUT_ABORT = 1;
var SERVER_ABORT = 2;
function getDoc(frame) {
/* it looks like contentWindow or contentDocument do not
* carry the protocol property in ie8, when running under ssl
* frame.document is the only valid response document, since
* the protocol is know but not on the other two objects. strange?
* "Same origin policy" http://en.wikipedia.org/wiki/Same_origin_policy
*/
var doc = null;
// IE8 cascading access check
try {
if (frame.contentWindow) {
doc = frame.contentWindow.document;
}
} catch (err) {
// IE8 access denied under ssl & missing protocol
log('cannot get iframe.contentWindow document: ' + err);
}
if (doc) { // successful getting content
return doc;
}
try { // simply checking may throw in ie8 under ssl or mismatched protocol
doc = frame.contentDocument ? frame.contentDocument : frame.document;
} catch (err) {
// last attempt
log('cannot get iframe.contentDocument: ' + err);
doc = frame.document;
}
return doc;
}
// Rails CSRF hack (thanks to Yvan Barthelemy)
var csrf_token = $('meta[name=csrf-token]').attr('content');
var csrf_param = $('meta[name=csrf-param]').attr('content');
if (csrf_param && csrf_token) {
s.extraData = s.extraData || {};
s.extraData[csrf_param] = csrf_token;
}
// take a breath so that pending repaints get some cpu time before the upload starts
function doSubmit() {
// make sure form attrs are set
var t = $form.attr2('target'),
a = $form.attr2('action'),
mp = 'multipart/form-data',
et = $form.attr('enctype') || $form.attr('encoding') || mp;
// update form attrs in IE friendly way
form.setAttribute('target', id);
if (!method || /post/i.test(method)) {
form.setAttribute('method', 'POST');
}
if (a !== s.url) {
form.setAttribute('action', s.url);
}
// ie borks in some cases when setting encoding
if (!s.skipEncodingOverride && (!method || /post/i.test(method))) {
$form.attr({
encoding : 'multipart/form-data',
enctype : 'multipart/form-data'
});
}
// support timout
if (s.timeout) {
timeoutHandle = setTimeout(function() {
timedOut = true; cb(CLIENT_TIMEOUT_ABORT);
}, s.timeout);
}
// look for server aborts
function checkState() {
try {
var state = getDoc(io).readyState;
log('state = ' + state);
if (state && state.toLowerCase() === 'uninitialized') {
setTimeout(checkState, 50);
}
} catch (e) {
log('Server abort: ', e, ' (', e.name, ')');
cb(SERVER_ABORT); // eslint-disable-line callback-return
if (timeoutHandle) {
clearTimeout(timeoutHandle);
}
timeoutHandle = undefined;
}
}
// add "extra" data to form if provided in options
var extraInputs = [];
try {
if (s.extraData) {
for (var n in s.extraData) {
if (s.extraData.hasOwnProperty(n)) {
// if using the $.param format that allows for multiple values with the same name
if ($.isPlainObject(s.extraData[n]) && s.extraData[n].hasOwnProperty('name') && s.extraData[n].hasOwnProperty('value')) {
extraInputs.push(
$('<input type="hidden" name="' + s.extraData[n].name + '">', ownerDocument).val(s.extraData[n].value)
.appendTo(form)[0]);
} else {
extraInputs.push(
$('<input type="hidden" name="' + n + '">', ownerDocument).val(s.extraData[n])
.appendTo(form)[0]);
}
}
}
}
if (!s.iframeTarget) {
// add iframe to doc and submit the form
$io.appendTo($body);
}
if (io.attachEvent) {
io.attachEvent('onload', cb);
} else {
io.addEventListener('load', cb, false);
}
setTimeout(checkState, 15);
try {
form.submit();
} catch (err) {
// just in case form has element with name/id of 'submit'
var submitFn = document.createElement('form').submit;
submitFn.apply(form);
}
} finally {
// reset attrs and remove "extra" input elements
form.setAttribute('action', a);
form.setAttribute('enctype', et); // #380
if (t) {
form.setAttribute('target', t);
} else {
$form.removeAttr('target');
}
$(extraInputs).remove();
}
}
if (s.forceSync) {
doSubmit();
} else {
setTimeout(doSubmit, 10); // this lets dom updates render
}
var data, doc, domCheckCount = 50, callbackProcessed;
function cb(e) {
if (xhr.aborted || callbackProcessed) {
return;
}
doc = getDoc(io);
if (!doc) {
log('cannot access response document');
e = SERVER_ABORT;
}
if (e === CLIENT_TIMEOUT_ABORT && xhr) {
xhr.abort('timeout');
deferred.reject(xhr, 'timeout');
return;
}
if (e === SERVER_ABORT && xhr) {
xhr.abort('server abort');
deferred.reject(xhr, 'error', 'server abort');
return;
}
if (!doc || doc.location.href === s.iframeSrc) {
// response not received yet
if (!timedOut) {
return;
}
}
if (io.detachEvent) {
io.detachEvent('onload', cb);
} else {
io.removeEventListener('load', cb, false);
}
var status = 'success', errMsg;
try {
if (timedOut) {
throw 'timeout';
}
var isXml = s.dataType === 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
log('isXml=' + isXml);
if (!isXml && window.opera && (doc.body === null || !doc.body.innerHTML)) {
if (--domCheckCount) {
// in some browsers (Opera) the iframe DOM is not always traversable when
// the onload callback fires, so we loop a bit to accommodate
log('requeing onLoad callback, DOM not available');
setTimeout(cb, 250);
return;
}
// let this fall through because server response could be an empty document
// log('Could not access iframe DOM after mutiple tries.');
// throw 'DOMException: not available';
}
// log('response detected');
var docRoot = doc.body ? doc.body : doc.documentElement;
xhr.responseText = docRoot ? docRoot.innerHTML : null;
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
if (isXml) {
s.dataType = 'xml';
}
xhr.getResponseHeader = function(header){
var headers = {'content-type': s.dataType};
return headers[header.toLowerCase()];
};
// support for XHR 'status' & 'statusText' emulation :
if (docRoot) {
xhr.status = Number(docRoot.getAttribute('status')) || xhr.status;
xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText;
}
var dt = (s.dataType || '').toLowerCase();
var scr = /(json|script|text)/.test(dt);
if (scr || s.textarea) {
// see if user embedded response in textarea
var ta = doc.getElementsByTagName('textarea')[0];
if (ta) {
xhr.responseText = ta.value;
// support for XHR 'status' & 'statusText' emulation :
xhr.status = Number(ta.getAttribute('status')) || xhr.status;
xhr.statusText = ta.getAttribute('statusText') || xhr.statusText;
} else if (scr) {
// account for browsers injecting pre around json response
var pre = doc.getElementsByTagName('pre')[0];
var b = doc.getElementsByTagName('body')[0];
if (pre) {
xhr.responseText = pre.textContent ? pre.textContent : pre.innerText;
} else if (b) {
xhr.responseText = b.textContent ? b.textContent : b.innerText;
}
}
} else if (dt === 'xml' && !xhr.responseXML && xhr.responseText) {
xhr.responseXML = toXml(xhr.responseText); // eslint-disable-line no-use-before-define
}
try {
data = httpData(xhr, dt, s); // eslint-disable-line no-use-before-define
} catch (err) {
status = 'parsererror';
xhr.error = errMsg = (err || status);
}
} catch (err) {
log('error caught: ', err);
status = 'error';
xhr.error = errMsg = (err || status);
}
if (xhr.aborted) {
log('upload aborted');
status = null;
}
if (xhr.status) { // we've set xhr.status
status = ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) ? 'success' : 'error';
}
// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
if (status === 'success') {
if (s.success) {
s.success.call(s.context, data, 'success', xhr);
}
deferred.resolve(xhr.responseText, 'success', xhr);
if (g) {
$.event.trigger('ajaxSuccess', [xhr, s]);
}
} else if (status) {
if (typeof errMsg === 'undefined') {
errMsg = xhr.statusText;
}
if (s.error) {
s.error.call(s.context, xhr, status, errMsg);
}
deferred.reject(xhr, 'error', errMsg);
if (g) {
$.event.trigger('ajaxError', [xhr, s, errMsg]);
}
}
if (g) {
$.event.trigger('ajaxComplete', [xhr, s]);
}
if (g && !--$.active) {
$.event.trigger('ajaxStop');
}
if (s.complete) {
s.complete.call(s.context, xhr, status);
}
callbackProcessed = true;
if (s.timeout) {
clearTimeout(timeoutHandle);
}
// clean up
setTimeout(function() {
if (!s.iframeTarget) {
$io.remove();
} else { // adding else to clean up existing iframe response.
$io.attr('src', s.iframeSrc);
}
xhr.responseXML = null;
}, 100);
}
var toXml = $.parseXML || function(s, doc) { // use parseXML if available (jQuery 1.5+)
if (window.ActiveXObject) {
doc = new ActiveXObject('Microsoft.XMLDOM');
doc.async = 'false';
doc.loadXML(s);
} else {
doc = (new DOMParser()).parseFromString(s, 'text/xml');
}
return (doc && doc.documentElement && doc.documentElement.nodeName !== 'parsererror') ? doc : null;
};
var parseJSON = $.parseJSON || function(s) {
/* jslint evil:true */
return window['eval']('(' + s + ')'); // eslint-disable-line dot-notation
};
var httpData = function(xhr, type, s) { // mostly lifted from jq1.4.4
var ct = xhr.getResponseHeader('content-type') || '',
xml = ((type === 'xml' || !type) && ct.indexOf('xml') >= 0),
data = xml ? xhr.responseXML : xhr.responseText;
if (xml && data.documentElement.nodeName === 'parsererror') {
if ($.error) {
$.error('parsererror');
}
}
if (s && s.dataFilter) {
data = s.dataFilter(data, type);
}
if (typeof data === 'string') {
if ((type === 'json' || !type) && ct.indexOf('json') >= 0) {
data = parseJSON(data);
} else if ((type === 'script' || !type) && ct.indexOf('javascript') >= 0) {
$.globalEval(data);
}
}
return data;
};
return deferred;
}
};
/**
* ajaxForm() provides a mechanism for fully automating form submission.
*
* The advantages of using this method instead of ajaxSubmit() are:
*
* 1: This method will include coordinates for <input type="image"> elements (if the element
* is used to submit the form).
* 2. This method will include the submit element's name/value data (for the element that was
* used to submit the form).
* 3. This method binds the submit() method to the form for you.
*
* The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
* passes the options argument along after properly binding events for submit elements and
* the form itself.
*/
$.fn.ajaxForm = function(options, data, dataType, onSuccess) {
if (typeof options === 'string' || (options === false && arguments.length > 0)) {
options = {
'url' : options,
'data' : data,
'dataType' : dataType
};
if (typeof onSuccess === 'function') {
options.success = onSuccess;
}
}
options = options || {};
options.delegation = options.delegation && $.isFunction($.fn.on);
// in jQuery 1.3+ we can fix mistakes with the ready state
if (!options.delegation && this.length === 0) {
var o = {s: this.selector, c: this.context};
if (!$.isReady && o.s) {
log('DOM not ready, queuing ajaxForm');
$(function() {
$(o.s, o.c).ajaxForm(options);
});
return this;
}
// is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
return this;
}
if (options.delegation) {
$(document)
.off('submit.form-plugin', this.selector, doAjaxSubmit)
.off('click.form-plugin', this.selector, captureSubmittingElement)
.on('submit.form-plugin', this.selector, options, doAjaxSubmit)
.on('click.form-plugin', this.selector, options, captureSubmittingElement);
return this;
}
return this.ajaxFormUnbind()
.on('submit.form-plugin', options, doAjaxSubmit)
.on('click.form-plugin', options, captureSubmittingElement);
};
// private event handlers
function doAjaxSubmit(e) {
/* jshint validthis:true */
var options = e.data;
if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
e.preventDefault();
$(e.target).closest('form').ajaxSubmit(options); // #365
}
}
function captureSubmittingElement(e) {
/* jshint validthis:true */
var target = e.target;
var $el = $(target);
if (!$el.is('[type=submit],[type=image]')) {
// is this a child element of the submit el? (ex: a span within a button)
var t = $el.closest('[type=submit]');
if (t.length === 0) {
return;
}
target = t[0];
}
var form = target.form;
form.clk = target;
if (target.type === 'image') {
if (typeof e.offsetX !== 'undefined') {
form.clk_x = e.offsetX;
form.clk_y = e.offsetY;
} else if (typeof $.fn.offset === 'function') {
var offset = $el.offset();
form.clk_x = e.pageX - offset.left;
form.clk_y = e.pageY - offset.top;
} else {
form.clk_x = e.pageX - target.offsetLeft;
form.clk_y = e.pageY - target.offsetTop;
}
}
// clear form vars
setTimeout(function() {
form.clk = form.clk_x = form.clk_y = null;
}, 100);
}
// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
$.fn.ajaxFormUnbind = function() {
return this.off('submit.form-plugin click.form-plugin');
};
/**
* formToArray() gathers form element data into an array of objects that can
* be passed to any of the following ajax functions: $.get, $.post, or load.
* Each object in the array has both a 'name' and 'value' property. An example of
* an array for a simple login form might be:
*
* [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
*
* It is this array that is passed to pre-submit callback functions provided to the
* ajaxSubmit() and ajaxForm() methods.
*/
$.fn.formToArray = function(semantic, elements, filtering) {
var a = [];
if (this.length === 0) {
return a;
}
var form = this[0];
var formId = this.attr('id');
var els = (semantic || typeof form.elements === 'undefined') ? form.getElementsByTagName('*') : form.elements;
var els2;
if (els) {
els = $.makeArray(els); // convert to standard array
}
// #386; account for inputs outside the form which use the 'form' attribute
// FinesseRus: in non-IE browsers outside fields are already included in form.elements.
if (formId && (semantic || /(Edge|Trident)\//.test(navigator.userAgent))) {
els2 = $(':input[form="' + formId + '"]').get(); // hat tip @thet
if (els2.length) {
els = (els || []).concat(els2);
}
}
if (!els || !els.length) {
return a;
}
if ($.isFunction(filtering)) {
els = $.map(els, filtering);
}
var i, j, n, v, el, max, jmax;
for (i = 0, max = els.length; i < max; i++) {
el = els[i];
n = el.name;
if (!n || el.disabled) {
continue;
}
if (semantic && form.clk && el.type === 'image') {
// handle image inputs on the fly when semantic == true
if (form.clk === el) {
a.push({name: n, value: $(el).val(), type: el.type});
a.push({name: n + '.x', value: form.clk_x}, {name: n + '.y', value: form.clk_y});
}
continue;
}
v = $.fieldValue(el, true);
if (v && v.constructor === Array) {
if (elements) {
elements.push(el);
}
for (j = 0, jmax = v.length; j < jmax; j++) {
a.push({name: n, value: v[j]});
}
} else if (feature.fileapi && el.type === 'file') {
if (elements) {
elements.push(el);
}
var files = el.files;
if (files.length) {
for (j = 0; j < files.length; j++) {
a.push({name: n, value: files[j], type: el.type});
}
} else {
// #180
a.push({name: n, value: '', type: el.type});
}
} else if (v !== null && typeof v !== 'undefined') {
if (elements) {
elements.push(el);
}
a.push({name: n, value: v, type: el.type, required: el.required});
}
}
if (!semantic && form.clk) {
// input type=='image' are not found in elements array! handle it here
var $input = $(form.clk), input = $input[0];
n = input.name;
if (n && !input.disabled && input.type === 'image') {
a.push({name: n, value: $input.val()});
a.push({name: n + '.x', value: form.clk_x}, {name: n + '.y', value: form.clk_y});
}
}
return a;
};
/**
* Serializes form data into a 'submittable' string. This method will return a string
* in the format: name1=value1&amp;name2=value2
*/
$.fn.formSerialize = function(semantic) {
// hand off to jQuery.param for proper encoding
return $.param(this.formToArray(semantic));
};
/**
* Serializes all field elements in the jQuery object into a query string.
* This method will return a string in the format: name1=value1&amp;name2=value2
*/
$.fn.fieldSerialize = function(successful) {
var a = [];
this.each(function() {
var n = this.name;
if (!n) {
return;
}
var v = $.fieldValue(this, successful);
if (v && v.constructor === Array) {
for (var i = 0, max = v.length; i < max; i++) {
a.push({name: n, value: v[i]});
}
} else if (v !== null && typeof v !== 'undefined') {
a.push({name: this.name, value: v});
}
});
// hand off to jQuery.param for proper encoding
return $.param(a);
};
/**
* Returns the value(s) of the element in the matched set. For example, consider the following form:
*
* <form><fieldset>
* <input name="A" type="text">
* <input name="A" type="text">
* <input name="B" type="checkbox" value="B1">
* <input name="B" type="checkbox" value="B2">
* <input name="C" type="radio" value="C1">
* <input name="C" type="radio" value="C2">
* </fieldset></form>
*
* var v = $('input[type=text]').fieldValue();
* // if no values are entered into the text inputs
* v === ['','']
* // if values entered into the text inputs are 'foo' and 'bar'
* v === ['foo','bar']
*
* var v = $('input[type=checkbox]').fieldValue();
* // if neither checkbox is checked
* v === undefined
* // if both checkboxes are checked
* v === ['B1', 'B2']
*
* var v = $('input[type=radio]').fieldValue();
* // if neither radio is checked
* v === undefined
* // if first radio is checked
* v === ['C1']
*
* The successful argument controls whether or not the field element must be 'successful'
* (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
* The default value of the successful argument is true. If this value is false the value(s)
* for each element is returned.
*
* Note: This method *always* returns an array. If no valid value can be determined the
* array will be empty, otherwise it will contain one or more values.
*/
$.fn.fieldValue = function(successful) {
for (var val = [], i = 0, max = this.length; i < max; i++) {
var el = this[i];
var v = $.fieldValue(el, successful);
if (v === null || typeof v === 'undefined' || (v.constructor === Array && !v.length)) {
continue;
}
if (v.constructor === Array) {
$.merge(val, v);
} else {
val.push(v);
}
}
return val;
};
/**
* Returns the value of the field element.
*/
$.fieldValue = function(el, successful) {
var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
if (typeof successful === 'undefined') {
successful = true;
}
/* eslint-disable no-mixed-operators */
if (successful && (!n || el.disabled || t === 'reset' || t === 'button' ||
(t === 'checkbox' || t === 'radio') && !el.checked ||
(t === 'submit' || t === 'image') && el.form && el.form.clk !== el ||
tag === 'select' && el.selectedIndex === -1)) {
/* eslint-enable no-mixed-operators */
return null;
}
if (tag === 'select') {
var index = el.selectedIndex;
if (index < 0) {
return null;
}
var a = [], ops = el.options;
var one = (t === 'select-one');
var max = (one ? index + 1 : ops.length);
for (var i = (one ? index : 0); i < max; i++) {
var op = ops[i];
if (op.selected && !op.disabled) {
var v = op.value;
if (!v) { // extra pain for IE...
v = (op.attributes && op.attributes.value && !(op.attributes.value.specified)) ? op.text : op.value;
}
if (one) {
return v;
}
a.push(v);
}
}
return a;
}
return $(el).val().replace(rCRLF, '\r\n');
};
/**
* Clears the form data. Takes the following actions on the form's input fields:
* - input text fields will have their 'value' property set to the empty string
* - select elements will have their 'selectedIndex' property set to -1
* - checkbox and radio inputs will have their 'checked' property set to false
* - inputs of type submit, button, reset, and hidden will *not* be effected
* - button elements will *not* be effected
*/
$.fn.clearForm = function(includeHidden) {
return this.each(function() {
$('input,select,textarea', this).clearFields(includeHidden);
});
};
/**
* Clears the selected form elements.
*/
$.fn.clearFields = $.fn.clearInputs = function(includeHidden) {
var re = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i; // 'hidden' is not in this list
return this.each(function() {
var t = this.type, tag = this.tagName.toLowerCase();
if (re.test(t) || tag === 'textarea') {
this.value = '';
} else if (t === 'checkbox' || t === 'radio') {
this.checked = false;
} else if (tag === 'select') {
this.selectedIndex = -1;
} else if (t === 'file') {
if (/MSIE/.test(navigator.userAgent)) {
$(this).replaceWith($(this).clone(true));
} else {
$(this).val('');
}
} else if (includeHidden) {
// includeHidden can be the value true, or it can be a selector string
// indicating a special test; for example:
// $('#myForm').clearForm('.special:hidden')
// the above would clean hidden inputs that have the class of 'special'
if ((includeHidden === true && /hidden/.test(t)) ||
(typeof includeHidden === 'string' && $(this).is(includeHidden))) {
this.value = '';
}
}
});
};
/**
* Resets the form data or individual elements. Takes the following actions
* on the selected tags:
* - all fields within form elements will be reset to their original value
* - input / textarea / select fields will be reset to their original value
* - option / optgroup fields (for multi-selects) will defaulted individually
* - non-multiple options will find the right select to default
* - label elements will be searched against its 'for' attribute
* - all others will be searched for appropriate children to default
*/
$.fn.resetForm = function() {
return this.each(function() {
var el = $(this);
var tag = this.tagName.toLowerCase();
switch (tag) {
case 'input':
this.checked = this.defaultChecked;
// fall through
case 'textarea':
this.value = this.defaultValue;
return true;
case 'option':
case 'optgroup':
var select = el.parents('select');
if (select.length && select[0].multiple) {
if (tag === 'option') {
this.selected = this.defaultSelected;
} else {
el.find('option').resetForm();
}
} else {
select.resetForm();
}
return true;
case 'select':
el.find('option').each(function(i) { // eslint-disable-line consistent-return
this.selected = this.defaultSelected;
if (this.defaultSelected && !el[0].multiple) {
el[0].selectedIndex = i;
return false;
}
});
return true;
case 'label':
var forEl = $(el.attr('for'));
var list = el.find('input,select,textarea');
if (forEl[0]) {
list.unshift(forEl[0]);
}
list.resetForm();
return true;
case 'form':
// guard against an input with the name of 'reset'
// note that IE reports the reset function as an 'object'
if (typeof this.reset === 'function' || (typeof this.reset === 'object' && !this.reset.nodeType)) {
this.reset();
}
return true;
default:
el.find('form,input,label,select,textarea').resetForm();
return true;
}
});
};
/**
* Enables or disables any matching elements.
*/
$.fn.enable = function(b) {
if (typeof b === 'undefined') {
b = true;
}
return this.each(function() {
this.disabled = !b;
});
};
/**
* Checks/unchecks any matching checkboxes or radio buttons and
* selects/deselects and matching option elements.
*/
$.fn.selected = function(select) {
if (typeof select === 'undefined') {
select = true;
}
return this.each(function() {
var t = this.type;
if (t === 'checkbox' || t === 'radio') {
this.checked = select;
} else if (this.tagName.toLowerCase() === 'option') {
var $sel = $(this).parent('select');
if (select && $sel[0] && $sel[0].type === 'select-one') {
// deselect all other options
$sel.find('option').selected(false);
}
this.selected = select;
}
});
};
// expose debug var
$.fn.ajaxSubmit.debug = false;
// helper fn for console logging
function log() {
if (!$.fn.ajaxSubmit.debug) {
return;
}
var msg = '[jquery.form] ' + Array.prototype.join.call(arguments, '');
if (window.console && window.console.log) {
window.console.log(msg);
} else if (window.opera && window.opera.postError) {
window.opera.postError(msg);
}
}
}));
<?php
///*
//Server-side PHP file upload code for HTML5 File Drag & Drop demonstration
//Featured on SitePoint.com
//Developed by Craig Buckler (@craigbuckler) of OptimalWorks.net
//*/
$fn = (isset($_SERVER['HTTP_X_FILENAME']) ? $_SERVER['HTTP_X_FILENAME'] : false);
if ($fn) {
// AJAX call
file_put_contents(
'uploads/' . $fn,
file_get_contents('php://input')
);
echo "$fn uploaded";
exit();
}
else {
// form submit
$files = $_FILES['myfile'];
$fn = $files['name'];
move_uploaded_file(
$files['tmp_name'],
'uploads/' . $fn
);
echo "<p>File $fn uploaded.</p>";
}
//
//$xhr = $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
//if (!$xhr)
// echo '<textarea>';
//?>
<!---->
<!--// main content of response here-->
<!---->
<?php
//if (!$xhr)
// echo '</textarea>';
//?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment