Require packs to be a tarball
This commit is contained in:
parent
95730da419
commit
95d0c646f9
3 changed files with 8 additions and 13 deletions
|
@ -66,11 +66,8 @@ class Pack
|
|||
throw new DisplayException('The file provided does not appear to be valid.');
|
||||
}
|
||||
|
||||
if (! in_array($data['file_upload']->getMimeType(), [
|
||||
'application/zip',
|
||||
'application/gzip',
|
||||
])) {
|
||||
throw new DisplayException('The file provided does not meet the required filetypes of application/zip or application/gzip.');
|
||||
if ($data['file_upload']->getMimeType() !== 'application/gzip') {
|
||||
throw new DisplayException('The file provided does not meet the required filetype of application/gzip.');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,8 +92,7 @@ class Pack
|
|||
|
||||
Storage::makeDirectory('packs/' . $pack->uuid);
|
||||
if (isset($data['file_upload'])) {
|
||||
$filename = ($data['file_upload']->getMimeType() === 'application/zip') ? 'archive.zip' : 'archive.tar.gz';
|
||||
$data['file_upload']->storeAs('packs/' . $pack->uuid, $filename);
|
||||
$data['file_upload']->storeAs('packs/' . $pack->uuid, 'archive.tar.gz');
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
|
@ -132,10 +128,9 @@ class Pack
|
|||
throw new DisplayException('The uploaded archive was unable to be opened.');
|
||||
}
|
||||
|
||||
$isZip = $zip->locateName('archive.zip');
|
||||
$isTar = $zip->locateName('archive.tar.gz');
|
||||
|
||||
if ($zip->locateName('import.json') === false || ($isZip === false && $isTar === false)) {
|
||||
if (! $zip->locateName('import.json') || ! $isTar) {
|
||||
throw new DisplayException('This contents of the provided archive were in an invalid format.');
|
||||
}
|
||||
|
||||
|
@ -156,7 +151,7 @@ class Pack
|
|||
]);
|
||||
|
||||
$pack = Models\ServicePack::findOrFail($id);
|
||||
if (! $zip->extractTo(storage_path('app/packs/' . $pack->uuid), ($isZip === false) ? 'archive.tar.gz' : 'archive.zip')) {
|
||||
if (! $zip->extractTo(storage_path('app/packs/' . $pack->uuid), 'archive.tar.gz')) {
|
||||
$pack->delete();
|
||||
throw new DisplayException('Unable to extract the archive file to the correct location.');
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@
|
|||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="text-muted"><small>If you wish to modify or upload a new file it should be uploaded to <code>{{ storage_path('app/packs/' . $pack->uuid) }}</code> as either <code>archive.zip</code> or <code>archive.tar.gz</code>.</small></p>
|
||||
<p class="text-muted"><small>If you wish to modify or upload a new file it should be uploaded to <code>{{ storage_path('app/packs/' . $pack->uuid) }}</code> as <code>archive.tar.gz</code>.</small></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -150,8 +150,8 @@
|
|||
<div class="row">
|
||||
<div class="form-group col-md-12">
|
||||
<label class="control-label">Package Archive:</label>
|
||||
<input name="file_upload" type="file" accept=".zip,.tar.gz, application/zip, application/gzip" />
|
||||
<p class="text-muted"><small>This package file must either be a <code>.zip</code> or <code>.tar.gz</code> archive of files to use for either building or running this pack.<br /><br />If your file is larger than <code>20MB</code> we recommend uploading it using SFTP. Once you have added this pack to the system, a path will be provided where you should upload the file.
|
||||
<input name="file_upload" type="file" accept=".tar.gz, application/gzip" />
|
||||
<p class="text-muted"><small>This package file must be a <code>.tar.gz</code> archive of files to use for either building or running this pack.<br /><br />If your file is larger than <code>20MB</code> we recommend uploading it using SFTP. Once you have added this pack to the system, a path will be provided where you should upload the file.
|
||||
This server is currently configured with the following limits: <code>upload_max_filesize={{ ini_get('upload_max_filesize') }}</code> and <code>post_max_size={{ ini_get('post_max_size') }}</code>. If your file is larger than either of those values this request will fail.</small></p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue