Compare commits

..

No commits in common. "b7112238c3144b386ff58d962f56a53145ddfbb9" and "f2cdfdf5f143f95cc9e21198536e2eded984a497" have entirely different histories.

3 changed files with 19 additions and 37 deletions

View file

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