tos目录位置 与 文件类型

This commit is contained in:
jonathang4 2025-08-27 19:23:50 +08:00
parent 46fd921b23
commit 6753c1f16c
4 changed files with 7 additions and 7 deletions

View File

@ -67,7 +67,7 @@
"created": 1703123456, "created": 1703123456,
"data": { "data": {
"task_id": "task_123", "task_id": "task_123",
"url": "https://your-domain.com/images/image-1703123456-abc123.webp", "url": "https://your-domain.com/images/image-1703123456-abc123.png",
"status": -1 "status": -1
} }
} }
@ -115,7 +115,7 @@ TOS_ENDPOINT=tos-cn-beijing.volces.com
## 文件存储路径 ## 文件存储路径
- **图片**: `images/image-{timestamp}-{random}.webp` - **图片**: `images/image-{timestamp}-{random}.png`
- **视频**: `videos/video-{timestamp}-{random}.mp4` - **视频**: `videos/video-{timestamp}-{random}.mp4`
## 错误处理 ## 错误处理

View File

@ -83,9 +83,9 @@ export class ImagesTaskCache {
for (const imageUrl of imageUrls) { for (const imageUrl of imageUrls) {
try { try {
// 从URL获取文件名 // 从URL获取文件名
const fileName = `image-${Date.now()}-${Math.random().toString(36).substr(2, 9)}.webp`; const fileName = `image-${Date.now()}-${Math.random().toString(36).substr(2, 9)}.png`;
// 上传到TOS // 上传到TOS
const tosUrl = await TOSService.uploadFromUrl(imageUrl, `images/${fileName}`); const tosUrl = await TOSService.uploadFromUrl(imageUrl, `jimeng_free/images/${fileName}`);
tosUrls.push(tosUrl); tosUrls.push(tosUrl);
logger.info(`图片上传到TOS成功: ${imageUrl} -> ${tosUrl}`); logger.info(`图片上传到TOS成功: ${imageUrl} -> ${tosUrl}`);
} catch (error) { } catch (error) {

View File

@ -85,7 +85,7 @@ export class VideoTaskCache {
// 从URL获取文件名 // 从URL获取文件名
const fileName = `video-${Date.now()}-${Math.random().toString(36).substr(2, 9)}.mp4`; const fileName = `video-${Date.now()}-${Math.random().toString(36).substr(2, 9)}.mp4`;
// 上传到TOS // 上传到TOS
const tosUrl = await TOSService.uploadFromUrl(videoUrl, `videos/${fileName}`); const tosUrl = await TOSService.uploadFromUrl(videoUrl, `jimeng_free/videos/${fileName}`);
tosUrls.push(tosUrl); tosUrls.push(tosUrl);
logger.info(`视频上传到TOS成功: ${videoUrl} -> ${tosUrl}`); logger.info(`视频上传到TOS成功: ${videoUrl} -> ${tosUrl}`);
} catch (error) { } catch (error) {

View File

@ -752,11 +752,11 @@ export class TaskPollingService {
for (const url of urls) { for (const url of urls) {
try { try {
const fileName = taskType === 'image' const fileName = taskType === 'image'
? `image-${Date.now()}-${Math.random().toString(36).substr(2, 9)}.webp` ? `image-${Date.now()}-${Math.random().toString(36).substr(2, 9)}.png`
: `video-${Date.now()}-${Math.random().toString(36).substr(2, 9)}.mp4`; : `video-${Date.now()}-${Math.random().toString(36).substr(2, 9)}.mp4`;
const folder = taskType === 'image' ? 'images' : 'videos'; const folder = taskType === 'image' ? 'images' : 'videos';
const tosUrl = await TOSService.uploadFromUrl(url, `${folder}/${fileName}`); const tosUrl = await TOSService.uploadFromUrl(url, `jimeng_free/${folder}/${fileName}`);
tosUrls.push(tosUrl); tosUrls.push(tosUrl);
taskLog(`${taskType} uploaded to TOS: ${url} -> ${tosUrl}`); taskLog(`${taskType} uploaded to TOS: ${url} -> ${tosUrl}`);