Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx-web
/
glsk-oss-jssdk
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 42814efb
authored
May 11, 2026
by
岑成威
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix:统一格式化jpg
1 parent
e41073c5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
package.json
src/index.js
package.json
View file @
42814ef
{
"name"
:
"glsk-oss-jssdk"
,
"version"
:
"1.0.
6
"
,
"version"
:
"1.0.
7
"
,
"description"
:
"glsk-oss-jssdk"
,
"main"
:
"src/index.js"
,
"scripts"
:
{
...
...
src/index.js
View file @
42814ef
...
...
@@ -4,6 +4,7 @@ import OssConfigService from '../api/ossConfigService' // 导入配置服务
class
GlOssApi
{
constructor
(
params
=
{})
{
this
.
baseConfig
=
null
this
.
defaultImageProcess
=
params
?.
defaultImageProcess
??
'image/format,jpg'
}
/**
...
...
@@ -25,8 +26,9 @@ class GlOssApi {
* @param {Object} compressObj 压缩配置对象(可选)
* @param {number} partSize 分片大小(单位 KB,默认500KB)
* @param {number} maxRetries 最大重试次数(默认3次)
* @param {string|null} imageProcess OSS图片处理参数(可选),例如:'image/format,png'。传null表示不拼接x-oss-process
*/
async
multipartUpload
(
file
,
successCallback
=
()
=>
{},
errCallBack
=
()
=>
{},
bucketName
=
'zzl-filerepostorypublic'
,
dir
=
'image'
,
custAttrObj
=
{
systemSource
:
'dj'
},
compressObj
=
{},
partSize
=
500
,
maxRetries
=
3
)
{
async
multipartUpload
(
file
,
successCallback
=
()
=>
{},
errCallBack
=
()
=>
{},
bucketName
=
'zzl-filerepostorypublic'
,
dir
=
'image'
,
custAttrObj
=
{
systemSource
:
'dj'
},
compressObj
=
{},
partSize
=
500
,
maxRetries
=
3
,
imageProcess
=
null
)
{
try
{
// 获取基础配置并动态设置baseURL到httpClient
this
.
baseConfig
=
await
OssConfigService
.
fetchBaseConfig
()
...
...
@@ -70,9 +72,15 @@ class GlOssApi {
const
url
=
aliyunAddress
.
split
(
'?'
)[
0
].
split
(
'https:'
)[
1
]
const
encodedUrl
=
this
.
encodeOSSFilename
(
decodeURIComponent
(
url
))
const
finalImageProcess
=
imageProcess
??
this
.
defaultImageProcess
const
publicUrl
=
`https:
${
encodedUrl
}
`
const
processedUrl
=
finalImageProcess
?
`
${
publicUrl
}
?x-oss-process=
${
encodeURIComponent
(
finalImageProcess
)}
`
:
publicUrl
successCallback
({
attachment
:
fileName
,
aliyunAddress
:
`https:
${
encodedUrl
}
`
,
aliyunAddress
:
processedUrl
,
size
})
}
catch
(
err
)
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment