mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-01-23 05:52:15 +08:00
refactor upload command
This commit is contained in:
parent
2b283b727e
commit
6ed0e6bae0
@ -518,16 +518,20 @@ StepUploadPrepareUpload:
|
|||||||
ContentHashName: contentHashName,
|
ContentHashName: contentHashName,
|
||||||
ProofCode: proofCode,
|
ProofCode: proofCode,
|
||||||
ProofVersion: "v1",
|
ProofVersion: "v1",
|
||||||
|
LocalCreatedAt: utils.UnixTime2LocalFormatStr(utu.LocalFileChecksum.ModTime),
|
||||||
|
LocalModifiedAt: utils.UnixTime2LocalFormatStr(utu.LocalFileChecksum.ModTime),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 不支持秒传,不计算SHA1,直接上传文件
|
// 不支持秒传,不计算SHA1,直接上传文件
|
||||||
appCreateUploadFileParam = &aliyunpan.CreateFileUploadParam{
|
appCreateUploadFileParam = &aliyunpan.CreateFileUploadParam{
|
||||||
DriveId: utu.DriveId,
|
DriveId: utu.DriveId,
|
||||||
Name: filepath.Base(utu.SavePath),
|
Name: filepath.Base(utu.SavePath),
|
||||||
Size: utu.LocalFileChecksum.Length,
|
Size: utu.LocalFileChecksum.Length,
|
||||||
CheckNameMode: checkNameMode,
|
CheckNameMode: checkNameMode,
|
||||||
ParentFileId: rs.FileId,
|
ParentFileId: rs.FileId,
|
||||||
BlockSize: utu.BlockSize,
|
BlockSize: utu.BlockSize,
|
||||||
|
LocalCreatedAt: utils.UnixTime2LocalFormatStr(utu.LocalFileChecksum.ModTime),
|
||||||
|
LocalModifiedAt: utils.UnixTime2LocalFormatStr(utu.LocalFileChecksum.ModTime),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,10 +94,3 @@ func CalcFilePreHash(filePath string) string {
|
|||||||
hashCode := hex.EncodeToString(shaBytes)
|
hashCode := hex.EncodeToString(shaBytes)
|
||||||
return strings.ToUpper(hashCode)
|
return strings.ToUpper(hashCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnixTime2LocalFormatStr 时间戳转换为东8区时间字符串
|
|
||||||
func UnixTime2LocalFormatStr(unixTime int64) string {
|
|
||||||
t := time.Unix(unixTime, 0)
|
|
||||||
cz := time.FixedZone("CST", 8*3600) // 东8区
|
|
||||||
return t.In(cz).Format("2006-01-02T15:04:05.000Z")
|
|
||||||
}
|
|
||||||
|
@ -506,6 +506,8 @@ func (f *FileActionTask) uploadFile(ctx context.Context) error {
|
|||||||
BlockSize: f.syncItem.UploadBlockSize,
|
BlockSize: f.syncItem.UploadBlockSize,
|
||||||
ProofCode: proofCode,
|
ProofCode: proofCode,
|
||||||
ProofVersion: "v1",
|
ProofVersion: "v1",
|
||||||
|
LocalCreatedAt: utils.UnixTime2LocalFormatStr(localFile.ModTime),
|
||||||
|
LocalModifiedAt: utils.UnixTime2LocalFormatStr(localFile.ModTime),
|
||||||
}
|
}
|
||||||
if uploadOpEntity, err := f.panClient.OpenapiPanClient().CreateUploadFile(appCreateUploadFileParam); err != nil {
|
if uploadOpEntity, err := f.panClient.OpenapiPanClient().CreateUploadFile(appCreateUploadFileParam); err != nil {
|
||||||
logger.Verbosef("创建云盘上传任务失败: %s\n", targetPanFilePath)
|
logger.Verbosef("创建云盘上传任务失败: %s\n", targetPanFilePath)
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
//
|
//
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
//
|
//
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@ -281,3 +281,10 @@ func ResizeUploadBlockSize(fileSize, defaultBlockSize int64) int64 {
|
|||||||
sizeOfMB := int64(math.Ceil(float64(fileSize) / float64(aliyunpan.MaxPartNum) / 1024.0))
|
sizeOfMB := int64(math.Ceil(float64(fileSize) / float64(aliyunpan.MaxPartNum) / 1024.0))
|
||||||
return sizeOfMB * 1024
|
return sizeOfMB * 1024
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnixTime2LocalFormatStr 时间戳转换为东8区时间字符串
|
||||||
|
func UnixTime2LocalFormatStr(unixTime int64) string {
|
||||||
|
t := time.Unix(unixTime, 0)
|
||||||
|
cz := time.FixedZone("CST", 8*3600) // 东8区
|
||||||
|
return t.In(cz).Format("2006-01-02T15:04:05.000Z")
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user