Browse Source

obs key

tags/v1.21.12.1
yuyuanshifu 5 years ago
parent
commit
596bbdfa58
2 changed files with 10 additions and 6 deletions
  1. +4
    -0
      routers/repo/attachment.go
  2. +6
    -6
      web_src/js/components/ObsUploader.vue

+ 4
- 0
routers/repo/attachment.go View File

@@ -609,6 +609,10 @@ func GetObsKey(ctx *context.Context) {
ctx.JSON(200, map[string]string{ ctx.JSON(200, map[string]string{
"uuid": uuid, "uuid": uuid,
"key": key, "key": key,
"access_key_id": setting.AccessKeyID,
"secret_access_key": setting.SecretAccessKey,
"server": setting.Endpoint,
"bucket": setting.Bucket,
}) })
} }




+ 6
- 6
web_src/js/components/ObsUploader.vue View File

@@ -142,11 +142,11 @@ export default {
}, },


// 构建ObsClient // 构建ObsClient
getObsClient(){
getObsClient(result){
return new ObsClient({ return new ObsClient({
access_key_id: 'FDP3LRMHLB9S77VWEHE3',
secret_access_key: 'LyM82Wk80pgjhs2z7AdDcsdpCWhbsJtSzQ7hkESN',
server : 'https://obs.cn-south-222.ai.pcl.cn'
access_key_id: result.access_key_id,
secret_access_key: result.secret_access_key,
server : result.server
}); });
}, },


@@ -157,13 +157,13 @@ export default {
const upload_datasetId = document const upload_datasetId = document
.getElementById('datasetId') .getElementById('datasetId')
.getAttribute('datasetId'); .getAttribute('datasetId');
const obsClient = this.getObsClient()
const obsClient = this.getObsClient(result)
const _this = this const _this = this
var cp; var cp;
var hook; var hook;


obsClient.uploadFile({ obsClient.uploadFile({
Bucket : 'testopendata',
Bucket : result.bucket,
Key : result.key, Key : result.key,
SourceFile : file, SourceFile : file,
PartSize : 64 * 1024 * 1024, PartSize : 64 * 1024 * 1024,


Loading…
Cancel
Save