panupload

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

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

View Source
const (
	// MaxUploadBlockSize 最大上传的文件分片大小
	MaxUploadBlockSize = 2 * converter.GB
	// MinUploadBlockSize 最小的上传的文件分片大小
	MinUploadBlockSize = 4 * converter.MB
	// MaxRapidUploadSize 秒传文件支持的最大文件大小
	MaxRapidUploadSize = 20 * converter.GB

	UploadingFileName = "aliyunpan_uploading.json"
)
View Source
const (
	// DefaultCheckPreHashFileSize PreHash计算文件大小门限,默认100MB以上文件才计算
	DefaultCheckPreHashFileSize = 100 * 1024 * 1024
)
View Source
const (
	StrUploadFailed = "上传文件失败"
)

Variables

This section is empty.

Functions

func CalcFilePreHash added in v0.3.0

func CalcFilePreHash(filePath string) string

CalcFilePreHash 计算文件 PreHash

func IsUrlExpired added in v0.1.6

func IsUrlExpired(urlStr string) bool

IsUrlExpired 上传链接是否已过期。过期返回True

func IsVideoFile added in v0.2.1

func IsVideoFile(fileName string) bool

func NewPanUpload

func NewPanUpload(panClient *config.PanClient, targetPath, driveId string, uploadOpEntity *aliyunpan.CreateFileUploadResult) uploader.MultiUpload

func UnixTime2LocalFormatStr added in v0.3.1

func UnixTime2LocalFormatStr(unixTime int64) string

UnixTime2LocalFormatStr 时间戳转换为东8区时间字符串

Types

type EmptyReaderLen64

type EmptyReaderLen64 struct {
}

func (EmptyReaderLen64) Len

func (e EmptyReaderLen64) Len() int64

func (EmptyReaderLen64) Read

func (e EmptyReaderLen64) Read(p []byte) (n int, err error)

type PanUpload

type PanUpload struct {
	// contains filtered or unexported fields
}

func (*PanUpload) CommitFile

func (pu *PanUpload) CommitFile() (cerr error)

func (*PanUpload) Precreate

func (pu *PanUpload) Precreate() (err error)

func (*PanUpload) UploadFile

func (pu *PanUpload) UploadFile(ctx context.Context, partseq int, partOffset int64, partEnd int64, r rio.ReaderLen64, uploadClient *requester.HTTPClient) (uploadDone bool, uperr error)

type StepUpload

type StepUpload int

StepUpload 上传步骤

const (
	// StepUploadInit 初始化步骤
	StepUploadInit StepUpload = iota
	// StepUploadPrepareUpload 上传前准备,创建上传任务
	StepUploadPrepareUpload
	// StepUploadRapidUpload 秒传步骤
	StepUploadRapidUpload
	// StepUploadUpload 正常上传步骤
	StepUploadUpload
)

type UploadStatistic

type UploadStatistic struct {
	functions.Statistic
}

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) Close

func (ud *UploadingDatabase) Close() error

Close 关闭数据库

func (*UploadingDatabase) Delete

func (ud *UploadingDatabase) Delete(meta *localfile.LocalFileMeta) bool

Delete 删除

func (*UploadingDatabase) Save

func (ud *UploadingDatabase) Save() error

Save 保存内容

func (*UploadingDatabase) Search

Search 搜索

func (*UploadingDatabase) UpdateUploading

func (ud *UploadingDatabase) UpdateUploading(meta *localfile.LocalFileMeta, state *uploader.InstanceState)

UpdateUploading 更新正在上传

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL