Implement creator studio and upload updates
This commit is contained in:
@@ -11,6 +11,7 @@ use Illuminate\Http\Client\PendingRequest;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
final class VisionService
|
||||
@@ -522,33 +523,29 @@ final class VisionService
|
||||
->first();
|
||||
|
||||
if ($row && ! empty($row->path)) {
|
||||
$storageRoot = rtrim((string) config('uploads.storage_root', ''), DIRECTORY_SEPARATOR);
|
||||
$absolute = $storageRoot . DIRECTORY_SEPARATOR . str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $row->path);
|
||||
if (is_file($absolute) && is_readable($absolute)) {
|
||||
$attach = Storage::disk((string) config('uploads.object_storage.disk', 's3'))->get((string) $row->path);
|
||||
if (is_string($attach) && $attach !== '') {
|
||||
$uploadUrl = rtrim($base, '/') . '/analyze/all/file';
|
||||
try {
|
||||
$attach = file_get_contents($absolute);
|
||||
if ($attach !== false) {
|
||||
/** @var \Illuminate\Http\Client\Response $uploadResp */
|
||||
$uploadResp = $this->requestWithVisionAuth('clip', $ref)
|
||||
->attach('file', $attach, basename($absolute))
|
||||
->post($uploadUrl, ['limit' => 5]);
|
||||
/** @var \Illuminate\Http\Client\Response $uploadResp */
|
||||
$uploadResp = $this->requestWithVisionAuth('clip', $ref)
|
||||
->attach('file', $attach, basename((string) $row->path))
|
||||
->post($uploadUrl, ['limit' => 5]);
|
||||
|
||||
if ($uploadResp->ok()) {
|
||||
$debug['fallback_upload'] = [
|
||||
'endpoint' => $uploadUrl,
|
||||
'status' => $uploadResp->status(),
|
||||
'response' => $uploadResp->json() ?? $this->safeBody($uploadResp->body()),
|
||||
];
|
||||
return ['tags' => $this->extractTagList($uploadResp->json()), 'debug' => $debug];
|
||||
}
|
||||
|
||||
Log::warning('CLIP upload fallback non-ok', [
|
||||
'ref' => $ref,
|
||||
if ($uploadResp->ok()) {
|
||||
$debug['fallback_upload'] = [
|
||||
'endpoint' => $uploadUrl,
|
||||
'status' => $uploadResp->status(),
|
||||
'body' => $this->safeBody($uploadResp->body()),
|
||||
]);
|
||||
'response' => $uploadResp->json() ?? $this->safeBody($uploadResp->body()),
|
||||
];
|
||||
return ['tags' => $this->extractTagList($uploadResp->json()), 'debug' => $debug];
|
||||
}
|
||||
|
||||
Log::warning('CLIP upload fallback non-ok', [
|
||||
'ref' => $ref,
|
||||
'status' => $uploadResp->status(),
|
||||
'body' => $this->safeBody($uploadResp->body()),
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('CLIP upload fallback failed', ['ref' => $ref, 'error' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user