|
|
@@ -181,17 +181,28 @@ func GetObsListObject(jobName, parentDir string) ([]FileInfo, error) { |
|
|
|
output, err := ObsCli.ListObjects(input) |
|
|
|
fileInfos := make([]FileInfo, 0) |
|
|
|
if err == nil { |
|
|
|
for index, val := range output.Contents { |
|
|
|
log.Info("Content[%d]-OwnerId:%s, ETag:%s, Key:%s, LastModified:%s, Size:%d\n", |
|
|
|
index, val.Owner.ID, val.ETag, val.Key, val.LastModified, val.Size) |
|
|
|
for _, val := range output.Contents { |
|
|
|
str1 := strings.Split(val.Key, "/") |
|
|
|
fileName := str1[len(str1)-1] |
|
|
|
log.Info("", fileName) |
|
|
|
var isDir bool |
|
|
|
var fileName,nextParentDir string |
|
|
|
if strings.HasSuffix(val.Key, "/") { |
|
|
|
fileName = str1[len(str1)-2] |
|
|
|
isDir = true |
|
|
|
nextParentDir = fileName |
|
|
|
if fileName == parentDir || (fileName + "/") == setting.OutPutPath { |
|
|
|
continue |
|
|
|
} |
|
|
|
} else { |
|
|
|
fileName = str1[len(str1)-1] |
|
|
|
isDir = false |
|
|
|
} |
|
|
|
|
|
|
|
fileInfo := FileInfo{ |
|
|
|
ModTime: val.LastModified.Format("2006-01-02 15:04:05"), |
|
|
|
FileName: fileName, |
|
|
|
Size: val.Size, |
|
|
|
IsDir:false, |
|
|
|
IsDir:isDir, |
|
|
|
ParenDir: nextParentDir, |
|
|
|
} |
|
|
|
fileInfos = append(fileInfos, fileInfo) |
|
|
|
} |
|
|
@@ -227,20 +238,17 @@ func ObsGenMultiPartSignedUrl(uuid string, uploadId string, partNumber int, file |
|
|
|
return output.SignedUrl, nil |
|
|
|
} |
|
|
|
|
|
|
|
func GetObsCreateSignedUrl(uuid string, uploadId string, partNumber int, fileName string) (string, error) { |
|
|
|
|
|
|
|
func GetObsCreateSignedUrl(jobName, parentDir, fileName string) (string, error) { |
|
|
|
input := &obs.CreateSignedUrlInput{} |
|
|
|
input.Bucket = setting.Bucket |
|
|
|
input.Key = strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid, fileName)), "/") |
|
|
|
input.Key = strings.TrimPrefix(path.Join(setting.TrainJobModelPath, jobName, setting.OutPutPath, parentDir, fileName), "/") |
|
|
|
|
|
|
|
input.Expires = 60 * 60 |
|
|
|
input.Method = obs.HttpMethodPut |
|
|
|
|
|
|
|
input.QueryParams = map[string]string{ |
|
|
|
"partNumber": com.ToStr(partNumber, 10), |
|
|
|
"uploadId": uploadId, |
|
|
|
//"partSize": com.ToStr(partSize,10), |
|
|
|
} |
|
|
|
input.Method = obs.HttpMethodGet |
|
|
|
|
|
|
|
reqParams := make(map[string]string) |
|
|
|
reqParams["response-content-disposition"] = "attachment; filename=\"" + fileName + "\"" |
|
|
|
input.QueryParams = reqParams |
|
|
|
output, err := ObsCli.CreateSignedUrl(input) |
|
|
|
if err != nil { |
|
|
|
log.Error("CreateSignedUrl failed:", err.Error()) |
|
|
|