From 9411827961ba48980ca5df3f2e0afba4cf8d321c Mon Sep 17 00:00:00 2001 From: liuxianghui <519646741@qq.com> Date: Mon, 1 Nov 2021 15:10:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4obs=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/babylon/tool/babylon-tool.ts | 2 +- src/app/service/objects.service.ts | 28 ++++++++++++---------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/app/babylon/tool/babylon-tool.ts b/src/app/babylon/tool/babylon-tool.ts index 73fcd5d..b340304 100644 --- a/src/app/babylon/tool/babylon-tool.ts +++ b/src/app/babylon/tool/babylon-tool.ts @@ -129,7 +129,7 @@ export class BabylonTool { path = ConfigManager.c_resPath_assetsRoot + rootUrl; } else { - path = ObjectsService.baseUrl + path; //根据环境,动态改变桶名 + path = ObjectsService.getFullPath(path); //根据环境,动态改变桶名 } console.log("异步加载模型" + path + sceneFilename); diff --git a/src/app/service/objects.service.ts b/src/app/service/objects.service.ts index bc5ba11..af4280a 100644 --- a/src/app/service/objects.service.ts +++ b/src/app/service/objects.service.ts @@ -29,7 +29,6 @@ export class ObjectsService { static readonly c_apiRoot = "/api/Objects/";//普通上传的API根路径 static apiRoot_Multipart = "/api/";//分块上传的API根路径 - /** * 当前所处环境(打包前根据需要设置) */ @@ -40,13 +39,23 @@ export class ObjectsService { */ static baseUrl; + /** + * 组装完整路径 + * @param extensionPath 局部路径,也是序列化下来的那部分路径(从桶名的下一级开始) + * 例子1(三维预案的模型): extensionPath = ceshi/assets/主体/outDoor/a.gltf 返回值: /api/Objects/{桶名}/ceshi/assets/主体/outDoor/a.gltf, + * 例子2(非三维部分的图片):extensionPath = ceshi/web/a.rgb 返回值: /api/Objects/{桶名}/ceshi/web/a.rgb, + */ + static getFullPath(extensionPath: string) { + return ObjectsService.baseUrl + extensionPath; + } + /** * 根据所处环境不同,设置不同的桶名 */ obsRootByEnv = new Map([ [EnvironmentType.DevelopEditor, "sinochemweb/"], //开发与编辑 [EnvironmentType.Test, "sinochem3d/"],//测试 - [EnvironmentType.Production, "prod/"],//生产环境(根据需要设置) + [EnvironmentType.Production, "sinochem3d/"],//生产环境(根据需要设置)最好是与测试环境的桶名相同 ]); @@ -55,13 +64,6 @@ export class ObjectsService { ObjectsService.baseUrl = ObjectsService.c_apiRoot + bucketName; } - /** - * 组装完整路径 - */ - static getFullPath() { - - } - /** * 获取桶名 */ @@ -69,9 +71,6 @@ export class ObjectsService { return this.obsRootByEnv.get(ObjectsService.currentEnvironmentType); } - - - /** * 普通上传,单个文件上限5M */ @@ -79,12 +78,9 @@ export class ObjectsService { let formData = new FormData() formData.append("file", file, file.name) let data = { keepOriginalName: 'true' } - return this.http.post(ObjectsService.baseUrl + extensionPath, formData, { params: data }); + return this.http.post(ObjectsService.getFullPath(extensionPath), formData, { params: data }); } - - - //分块上传 postFile_MultipartUpload(extensionPath: string, file: File): Promise { // let formData = new FormData()