mirror of
https://github.com/claradex/nativegallery.git
synced 2024-11-15 11:39:07 +03:00
Compare commits
4 commits
f2cdfdf5f1
...
b7112238c3
Author | SHA1 | Date | |
---|---|---|---|
|
b7112238c3 | ||
|
2ec7b5c61a | ||
|
f90a179608 | ||
|
731ff61d78 |
3 changed files with 37 additions and 19 deletions
|
@ -38,25 +38,39 @@ class Upload
|
||||||
$cstrong = True;
|
$cstrong = True;
|
||||||
$filecdn = bin2hex(openssl_random_pseudo_bytes(64, $cstrong)) . '.' . $fileext;
|
$filecdn = bin2hex(openssl_random_pseudo_bytes(64, $cstrong)) . '.' . $fileext;
|
||||||
$folder = $location . $filecdn;
|
$folder = $location . $filecdn;
|
||||||
$s3 = new \Aws\S3\S3Client([
|
|
||||||
'region' => NGALLERY['root']['storage']['s3']['credentials']['region'],
|
if (strtolower (NGALLERY['root']['storage']['type']) == "s3")
|
||||||
'version' => NGALLERY['root']['storage']['s3']['credentials']['version'],
|
{
|
||||||
'credentials' => [
|
$s3 = new \Aws\S3\S3Client([
|
||||||
'key' => NGALLERY['root']['storage']['s3']['credentials']['key'],
|
'region' => NGALLERY['root']['storage']['s3']['credentials']['region'],
|
||||||
'secret' => NGALLERY['root']['storage']['s3']['credentials']['secret'],
|
'version' => NGALLERY['root']['storage']['s3']['credentials']['version'],
|
||||||
],
|
'credentials' => [
|
||||||
'endpoint' => NGALLERY['root']['storage']['s3']['domains']['gateway'],
|
'key' => NGALLERY['root']['storage']['s3']['credentials']['key'],
|
||||||
]);
|
'secret' => NGALLERY['root']['storage']['s3']['credentials']['secret'],
|
||||||
|
],
|
||||||
$s3->putObject([
|
'endpoint' => NGALLERY['root']['storage']['s3']['domains']['gateway'],
|
||||||
'Bucket' => NGALLERY['root']['storage']['s3']['credentials']['bucket'],
|
]);
|
||||||
'Key' => $location.$filecdn,
|
|
||||||
'SourceFile' => $tmpname
|
$s3->putObject([
|
||||||
]);
|
'Bucket' => NGALLERY['root']['storage']['s3']['credentials']['bucket'],
|
||||||
$this->type = $type;
|
'Key' => $location.$filecdn,
|
||||||
$this->src = NGALLERY['root']['storage']['s3']['domains']['public'] . '/' . $location . $filecdn;
|
'SourceFile' => $tmpname
|
||||||
$this->size = self::human_filesize(filesize($tmpname));
|
]);
|
||||||
$this->name = $name;
|
$this->type = $type;
|
||||||
|
$this->src = NGALLERY['root']['storage']['s3']['domains']['public'] . '/' . $location . $filecdn;
|
||||||
|
$this->size = self::human_filesize(filesize($tmpname));
|
||||||
|
$this->name = $name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@mkdir ("{$_SERVER['DOCUMENT_ROOT']}/uploads/{$location}");
|
||||||
|
move_uploaded_file ($tmpname, "{$_SERVER['DOCUMENT_ROOT']}/uploads/{$folder}");
|
||||||
|
|
||||||
|
$this->type = $type;
|
||||||
|
$this->src = "/uploads/{$folder}";
|
||||||
|
$this->size = self::human_filesize(filesize($tmpname));
|
||||||
|
$this->name = $name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public function getType()
|
public function getType()
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,6 +20,10 @@ ngallery:
|
||||||
websockets:
|
websockets:
|
||||||
messages: ""
|
messages: ""
|
||||||
storage:
|
storage:
|
||||||
|
|
||||||
|
# type: 's3' - загрузка файлов в хранилище S3 (Amazon S3, Cloudflare, MinIO и т.д)
|
||||||
|
# type: 'server' - загрузка файлов в папку uploads (hardcode)
|
||||||
|
|
||||||
type: 's3'
|
type: 's3'
|
||||||
s3:
|
s3:
|
||||||
domains:
|
domains:
|
||||||
|
|
0
uploads/.gitignore
vendored
Normal file
0
uploads/.gitignore
vendored
Normal file
Loading…
Reference in a new issue