Browse Source

store path mod

tags/v1.21.12.1
yuyuanshifu 4 years ago
parent
commit
eaeb6699c9
3 changed files with 9 additions and 9 deletions
  1. +1
    -1
      modules/modelarts/modelarts.go
  2. +6
    -6
      modules/storage/obs.go
  3. +2
    -2
      routers/repo/attachment.go

+ 1
- 1
modules/modelarts/modelarts.go View File

@@ -22,7 +22,7 @@ const (
)

func GenerateTask(ctx *context.Context, jobName, uuid, description string) error {
dataActualPath := setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/"
dataActualPath := setting.Bucket + "/" + setting.BasePath + path.Join(uuid[0:1], uuid[1:2]) + "/" + uuid + "/"
jobResult, err := CreateJob(models.CreateNotebookParams{
JobName: jobName,
Description:description,


+ 6
- 6
modules/storage/obs.go View File

@@ -37,7 +37,7 @@ func ObsHasObject(path string) (bool, error) {
}

func GetObsPartInfos(uuid string, uploadID string) (string, error) {
key := strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid)), "/")
key := strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid, uuid)), "/")

output, err := ObsCli.ListParts(&obs.ListPartsInput{
Bucket: setting.Bucket,
@@ -60,7 +60,7 @@ func GetObsPartInfos(uuid string, uploadID string) (string, error) {
func NewObsMultiPartUpload(uuid string) (string, error) {
input := &obs.InitiateMultipartUploadInput{}
input.Bucket = setting.Bucket
input.Key = strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid)), "/")
input.Key = strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid, uuid)), "/")

output, err := ObsCli.InitiateMultipartUpload(input)
if err != nil {
@@ -74,7 +74,7 @@ func NewObsMultiPartUpload(uuid string) (string, error) {
func CompleteObsMultiPartUpload(uuid string, uploadID string) error {
input := &obs.CompleteMultipartUploadInput{}
input.Bucket = setting.Bucket
input.Key = strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid)), "/")
input.Key = strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid, uuid)), "/")
input.UploadId = uploadID
output, err := ObsCli.ListParts(&obs.ListPartsInput{
Bucket: setting.Bucket,
@@ -105,7 +105,7 @@ func CompleteObsMultiPartUpload(uuid string, uploadID string) error {
func ObsUploadPart(uuid string, uploadId string, partNumber int, partSize int64, body io.Reader) (string, error) {
input := &obs.UploadPartInput{}
input.PartNumber = partNumber
input.Key = strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid)), "/")
input.Key = strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid, uuid)), "/")
input.UploadId = uploadId
input.Bucket = setting.Bucket
input.PartSize = partSize
@@ -141,7 +141,7 @@ func ObsGenMultiPartSignedUrl(uuid string, uploadId string, partNumber int, part

*/

Key := strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid)), "/")
Key := strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid, uuid)), "/")
req, err := ObsCli.CreateUploadPartSignedUrl(setting.Bucket, Key, uploadId, partNumber, partSize)
if err != nil {
log.Error("CreateSignedUrl failed:", err.Error())
@@ -158,7 +158,7 @@ func ObsGenMultiPartSignedUrl(uuid string, uploadId string, partNumber int, part
func ObsGetPreSignedUrl(uuid, fileName string) (string, error) {
input := &obs.CreateSignedUrlInput{}
input.Method = obs.HttpMethodGet
input.Key = strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid)), "/")
input.Key = strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid, uuid)), "/")
input.Bucket = setting.Bucket
input.Expires = 60 * 60


+ 2
- 2
routers/repo/attachment.go View File

@@ -309,7 +309,7 @@ func AddAttachment(ctx *context.Context) {
return
}
} else {
has, err = storage.ObsHasObject(setting.BasePath + models.AttachmentRelativePath(uuid))
has, err = storage.ObsHasObject(setting.BasePath + models.AttachmentRelativePath(uuid) + "/" + uuid)
if err != nil {
ctx.ServerError("ObsHasObject", err)
return
@@ -621,7 +621,7 @@ func GetMultipartUploadUrl(ctx *context.Context) {

func GetObsKey(ctx *context.Context) {
uuid := gouuid.NewV4().String()
key := strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid)), "/")
key := strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid, uuid)), "/")

ctx.JSON(200, map[string]string{
"uuid": uuid,


Loading…
Cancel
Save