tos目录位置 与 文件类型
This commit is contained in:
parent
46fd921b23
commit
6753c1f16c
@ -67,7 +67,7 @@
|
||||
"created": 1703123456,
|
||||
"data": {
|
||||
"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
|
||||
}
|
||||
}
|
||||
@ -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`
|
||||
|
||||
## 错误处理
|
||||
|
||||
@ -83,9 +83,9 @@ export class ImagesTaskCache {
|
||||
for (const imageUrl of imageUrls) {
|
||||
try {
|
||||
// 从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
|
||||
const tosUrl = await TOSService.uploadFromUrl(imageUrl, `images/${fileName}`);
|
||||
const tosUrl = await TOSService.uploadFromUrl(imageUrl, `jimeng_free/images/${fileName}`);
|
||||
tosUrls.push(tosUrl);
|
||||
logger.info(`图片上传到TOS成功: ${imageUrl} -> ${tosUrl}`);
|
||||
} catch (error) {
|
||||
|
||||
@ -85,7 +85,7 @@ export class VideoTaskCache {
|
||||
// 从URL获取文件名
|
||||
const fileName = `video-${Date.now()}-${Math.random().toString(36).substr(2, 9)}.mp4`;
|
||||
// 上传到TOS
|
||||
const tosUrl = await TOSService.uploadFromUrl(videoUrl, `videos/${fileName}`);
|
||||
const tosUrl = await TOSService.uploadFromUrl(videoUrl, `jimeng_free/videos/${fileName}`);
|
||||
tosUrls.push(tosUrl);
|
||||
logger.info(`视频上传到TOS成功: ${videoUrl} -> ${tosUrl}`);
|
||||
} catch (error) {
|
||||
|
||||
@ -752,11 +752,11 @@ export class TaskPollingService {
|
||||
for (const url of urls) {
|
||||
try {
|
||||
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`;
|
||||
|
||||
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);
|
||||
|
||||
taskLog(`${taskType} uploaded to TOS: ${url} -> ${tosUrl}`);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user