增加了手机操作端

This commit is contained in:
wushumin
2026-05-15 14:01:36 +08:00
parent 9aac78b8da
commit dd56e0861b
107 changed files with 23547 additions and 346 deletions

View File

@@ -81,6 +81,11 @@ class FileStorageService
}
public function putContents(string $relativePath, string $content): void
{
$this->putContentsWithMimeType($relativePath, $content);
}
public function putContentsWithMimeType(string $relativePath, string $content, string $mimeType = ''): void
{
$relativePath = $this->storagePath($relativePath);
@@ -94,10 +99,14 @@ class FileStorageService
file_put_contents($tmpFile, $content);
try {
$options = $mimeType !== '' ? [
OssClient::OSS_CONTENT_TYPE => $mimeType,
] : null;
$this->ossClient()->uploadFile(
$this->configService()->bucket(),
$this->configService()->objectKey($relativePath),
$tmpFile
$tmpFile,
$options
);
} finally {
if (file_exists($tmpFile)) {
@@ -118,7 +127,7 @@ class FileStorageService
try {
$key = $this->configService()->objectKey($relativePath);
$this->qiniuUploadFile($tmpFile, $key);
$this->qiniuUploadFile($tmpFile, $key, $mimeType !== '' ? $mimeType : 'application/octet-stream');
} finally {
if (file_exists($tmpFile)) {
@unlink($tmpFile);
@@ -273,18 +282,18 @@ class FileStorageService
);
}
private function qiniuUploadFile(string $filePath, string $key): void
private function qiniuUploadFile(string $filePath, string $key, string $mimeType = 'application/octet-stream'): void
{
$token = $this->qiniuAuth()->uploadToken($this->configService()->qiniuBucket(), $key);
try {
[$ret, $err] = $this->qiniuUploadManager()->putFile($token, $key, $filePath);
[$ret, $err] = $this->qiniuUploadManager()->putFile($token, $key, $filePath, null, $mimeType);
} catch (\Throwable $e) {
$err = $e;
}
if ($err !== null && $this->shouldRetryQiniuWithoutHttps($err)) {
try {
[$ret, $err] = $this->qiniuUploadManager(false)->putFile($token, $key, $filePath);
[$ret, $err] = $this->qiniuUploadManager(false)->putFile($token, $key, $filePath, null, $mimeType);
} catch (\Throwable $e) {
$err = $e;
}