|
|
|
@ -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, string>([ |
|
|
|
|
[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<Object> { |
|
|
|
|
// let formData = new FormData()
|
|
|
|
|