mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-19 20:00:54 +01:00
Resumable uploads
This commit is contained in:
parent
816d3b132a
commit
2b96818c74
@ -142,8 +142,10 @@ export class Et2File extends Et2InputWidget(LitElement)
|
||||
widget_id: this.id,
|
||||
},
|
||||
chunkSize: 1024 * 1024,
|
||||
// Disable checking for already uploaded chunks
|
||||
testChunks: false
|
||||
|
||||
// Checking for already uploaded chunks - resumable uploads
|
||||
testChunks: true,
|
||||
testTarget: this.egw().ajaxUrl("EGroupware\\Api\\Etemplate\\Widget\\File::ajax_test_chunk")
|
||||
};
|
||||
if(this.accept)
|
||||
{
|
||||
|
@ -119,9 +119,9 @@ class File extends Etemplate\Widget
|
||||
$widget = $template->getElementById($matches[1].':$cont[id]:'.$matches[3]);
|
||||
}
|
||||
$mime = null;
|
||||
if($widget && $widget->attrs['mime'])
|
||||
if($widget && ($widget->attrs['allow'] || $widget->attrs['mime']))
|
||||
{
|
||||
$mime = $widget->attrs['mime'];
|
||||
$mime = $widget->attrs['allow'] ?? $widget->attrs['mime'];
|
||||
}
|
||||
|
||||
// Check for legacy [] in id to indicate multiple - it changes format
|
||||
@ -160,6 +160,35 @@ class File extends Etemplate\Widget
|
||||
$response->data($file_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resumable uploads, check if a chunk is already present
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function ajax_test_chunk()
|
||||
{
|
||||
$request_id = str_replace(' ', '+', rawurldecode($_REQUEST['request_id']));
|
||||
$widget_id = $_REQUEST['widget_id'];
|
||||
if(!self::$request = Etemplate\Request::read($request_id))
|
||||
{
|
||||
header('HTTP/1.1 404 Session Not Found');
|
||||
return;
|
||||
}
|
||||
|
||||
// check the destination file (format <filename.ext>.part<#chunk>
|
||||
// the file is stored in a temporary directory
|
||||
$temp_dir = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . str_replace('/', '_', $_REQUEST['resumableIdentifier']);
|
||||
if(!file_exists($temp_dir))
|
||||
{
|
||||
//No content, file is not there
|
||||
return http_response_code(204);
|
||||
}
|
||||
else
|
||||
{
|
||||
$chunk_name = $temp_dir . '/' . str_replace('/', '_', $_REQUEST['resumableFilename']) . '.part' . (int)$_REQUEST['resumableChunkNumber'];
|
||||
return file_exists($chunk_name) ? http_response_code(200) : http_response_code(204);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Process one uploaded file. There should only be one per request...
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user