Documentation ¶
Overview ¶
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2020 tickstep & chenall
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func CalcFilePreHash(filePath string) string
- func IsUrlExpired(urlStr string) bool
- func IsVideoFile(fileName string) bool
- func NewPanUpload(panClient *config.PanClient, targetPath, driveId string, ...) uploader.MultiUpload
- func UnixTime2LocalFormatStr(unixTime int64) string
- type EmptyReaderLen64
- type PanUpload
- type StepUpload
- type UploadStatistic
- type UploadTaskUnit
- func (utu *UploadTaskUnit) OnCancel(lastRunResult *taskframework.TaskUnitRunResult)
- func (utu *UploadTaskUnit) OnComplete(lastRunResult *taskframework.TaskUnitRunResult)
- func (utu *UploadTaskUnit) OnFailed(lastRunResult *taskframework.TaskUnitRunResult)
- func (utu *UploadTaskUnit) OnRetry(lastRunResult *taskframework.TaskUnitRunResult)
- func (utu *UploadTaskUnit) OnSuccess(lastRunResult *taskframework.TaskUnitRunResult)
- func (utu *UploadTaskUnit) RetryWait() time.Duration
- func (utu *UploadTaskUnit) Run() (result *taskframework.TaskUnitRunResult)
- func (utu *UploadTaskUnit) SetTaskInfo(taskInfo *taskframework.TaskInfo)
- type Uploading
- type UploadingDatabase
- func (ud *UploadingDatabase) Close() error
- func (ud *UploadingDatabase) Delete(meta *localfile.LocalFileMeta) bool
- func (ud *UploadingDatabase) Save() error
- func (ud *UploadingDatabase) Search(meta *localfile.LocalFileMeta) *uploader.InstanceState
- func (ud *UploadingDatabase) UpdateUploading(meta *localfile.LocalFileMeta, state *uploader.InstanceState)
Constants ¶
const ( // MaxUploadBlockSize 最大上传的文件分片大小 MaxUploadBlockSize = 2 * converter.GB // MinUploadBlockSize 最小的上传的文件分片大小 MinUploadBlockSize = 4 * converter.MB // MaxRapidUploadSize 秒传文件支持的最大文件大小 MaxRapidUploadSize = 20 * converter.GB UploadingFileName = "aliyunpan_uploading.json" )
const (
// DefaultCheckPreHashFileSize PreHash计算文件大小门限,默认100MB以上文件才计算
DefaultCheckPreHashFileSize = 100 * 1024 * 1024
)
const (
StrUploadFailed = "上传文件失败"
)
Variables ¶
This section is empty.
Functions ¶
func CalcFilePreHash ¶ added in v0.3.0
CalcFilePreHash 计算文件 PreHash
func IsUrlExpired ¶ added in v0.1.6
IsUrlExpired 上传链接是否已过期。过期返回True
func IsVideoFile ¶ added in v0.2.1
func NewPanUpload ¶
func NewPanUpload(panClient *config.PanClient, targetPath, driveId string, uploadOpEntity *aliyunpan.CreateFileUploadResult) uploader.MultiUpload
func UnixTime2LocalFormatStr ¶ added in v0.3.1
UnixTime2LocalFormatStr 时间戳转换为东8区时间字符串
Types ¶
type EmptyReaderLen64 ¶
type EmptyReaderLen64 struct { }
func (EmptyReaderLen64) Len ¶
func (e EmptyReaderLen64) Len() int64
type PanUpload ¶
type PanUpload struct {
// contains filtered or unexported fields
}
func (*PanUpload) CommitFile ¶
func (*PanUpload) UploadFile ¶
type StepUpload ¶
type StepUpload int
StepUpload 上传步骤
const ( // StepUploadInit 初始化步骤 StepUploadInit StepUpload = iota // StepUploadPrepareUpload 上传前准备,创建上传任务 StepUploadPrepareUpload // StepUploadRapidUpload 秒传步骤 StepUploadRapidUpload // StepUploadUpload 正常上传步骤 StepUploadUpload )
type UploadStatistic ¶
type UploadTaskUnit ¶
type UploadTaskUnit struct { LocalFileChecksum *localfile.LocalFileEntity // 要上传的本地文件详情 Step StepUpload SavePath string // 保存路径 DriveId string // 网盘ID,例如:文件网盘,相册网盘 FolderCreateMutex *sync.Mutex PanClient *config.PanClient UploadingDatabase *UploadingDatabase // 数据库 Parallel int NoRapidUpload bool // 禁用秒传,无需计算SHA1,直接上传 BlockSize int64 // 分片大小 UploadStatistic *UploadStatistic ShowProgress bool IsOverwrite bool // 覆盖已存在的文件,如果同名文件已存在则移到回收站里 IsSkipSameName bool // 跳过已存在的文件,即使文件内容不一致(不检查SHA1) // 全局速度统计 GlobalSpeedsStat *speeds.Speeds // 上传文件记录器 FileRecorder *log.FileRecorder // contains filtered or unexported fields }
UploadTaskUnit 上传的任务单元
func (*UploadTaskUnit) OnCancel ¶ added in v0.1.4
func (utu *UploadTaskUnit) OnCancel(lastRunResult *taskframework.TaskUnitRunResult)
func (*UploadTaskUnit) OnComplete ¶
func (utu *UploadTaskUnit) OnComplete(lastRunResult *taskframework.TaskUnitRunResult)
func (*UploadTaskUnit) OnFailed ¶
func (utu *UploadTaskUnit) OnFailed(lastRunResult *taskframework.TaskUnitRunResult)
func (*UploadTaskUnit) OnRetry ¶
func (utu *UploadTaskUnit) OnRetry(lastRunResult *taskframework.TaskUnitRunResult)
func (*UploadTaskUnit) OnSuccess ¶
func (utu *UploadTaskUnit) OnSuccess(lastRunResult *taskframework.TaskUnitRunResult)
func (*UploadTaskUnit) RetryWait ¶
func (utu *UploadTaskUnit) RetryWait() time.Duration
func (*UploadTaskUnit) Run ¶
func (utu *UploadTaskUnit) Run() (result *taskframework.TaskUnitRunResult)
func (*UploadTaskUnit) SetTaskInfo ¶
func (utu *UploadTaskUnit) SetTaskInfo(taskInfo *taskframework.TaskInfo)
type Uploading ¶
type Uploading struct { *localfile.LocalFileMeta State *uploader.InstanceState `json:"state"` }
Uploading 未完成上传的信息
type UploadingDatabase ¶
type UploadingDatabase struct { UploadingList []*Uploading `json:"upload_state"` Timestamp int64 `json:"timestamp"` // contains filtered or unexported fields }
UploadingDatabase 未完成上传的数据库
func NewUploadingDatabase ¶
func NewUploadingDatabase() (ud *UploadingDatabase, err error)
NewUploadingDatabase 初始化未完成上传的数据库, 从库中读取内容
func (*UploadingDatabase) Delete ¶
func (ud *UploadingDatabase) Delete(meta *localfile.LocalFileMeta) bool
Delete 删除
func (*UploadingDatabase) Search ¶
func (ud *UploadingDatabase) Search(meta *localfile.LocalFileMeta) *uploader.InstanceState
Search 搜索
func (*UploadingDatabase) UpdateUploading ¶
func (ud *UploadingDatabase) UpdateUploading(meta *localfile.LocalFileMeta, state *uploader.InstanceState)
UpdateUploading 更新正在上传