This commit is contained in:
themohooks 2024-09-12 17:28:26 +03:00
commit 837d784487
5 changed files with 39 additions and 23 deletions

View file

@ -105,7 +105,7 @@ class Upload
'type' => 'none', 'type' => 'none',
) )
); );
} else if (explode($type, '/')[0] === 'image') { } else if (explode('/', $type)[0] === 'image') {
$exif = new EXIF($_FILES['image']['tmp_name']); $exif = new EXIF($_FILES['image']['tmp_name']);

View file

@ -36,9 +36,7 @@ class MainController
} }
public static function videoRules() public static function videoRules()
{ {
$_GLOBAL['rules'] = '/config/videoRules.html'; Page::set('VideoRules');
$_GLOBAL['title'] = 'Правила видеотеки';
Page::set('Rules');
} }
public static function update() public static function update()
{ {

View file

@ -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'],
'version' => NGALLERY['root']['storage']['s3']['credentials']['version'],
'credentials' => [
'key' => NGALLERY['root']['storage']['s3']['credentials']['key'],
'secret' => NGALLERY['root']['storage']['s3']['credentials']['secret'],
],
'endpoint' => NGALLERY['root']['storage']['s3']['domains']['gateway'],
]);
$s3->putObject([ if (strtolower (NGALLERY['root']['storage']['type']) == "s3")
'Bucket' => NGALLERY['root']['storage']['s3']['credentials']['bucket'], {
'Key' => $location.$filecdn, $s3 = new \Aws\S3\S3Client([
'SourceFile' => $tmpname 'region' => NGALLERY['root']['storage']['s3']['credentials']['region'],
]); 'version' => NGALLERY['root']['storage']['s3']['credentials']['version'],
$this->type = $type; 'credentials' => [
$this->src = NGALLERY['root']['storage']['s3']['domains']['public'] . '/' . $location . $filecdn; 'key' => NGALLERY['root']['storage']['s3']['credentials']['key'],
$this->size = self::human_filesize(filesize($tmpname)); 'secret' => NGALLERY['root']['storage']['s3']['credentials']['secret'],
$this->name = $name; ],
'endpoint' => NGALLERY['root']['storage']['s3']['domains']['gateway'],
]);
$s3->putObject([
'Bucket' => NGALLERY['root']['storage']['s3']['credentials']['bucket'],
'Key' => $location.$filecdn,
'SourceFile' => $tmpname
]);
$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()
{ {

View file

@ -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
View file