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.
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 ¶
const ( // CHECKSUM_MD5 获取文件的 md5 值 CHECKSUM_MD5 int = 1 << iota // CHECKSUM_CRC32 获取文件的 crc32 值 CHECKSUM_CRC32 )
const ( // DefaultBufSize 默认的bufSize DefaultBufSize = int(256 * converter.KB) )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type ChecksumWriteUnit ¶
type ChecksumWriteUnit struct { SliceEnd int64 End int64 SliceSum interface{} Sum interface{} OnlySliceSum bool ChecksumWriter ChecksumWriter // contains filtered or unexported fields }
type ChecksumWriter ¶
func NewHash32ChecksumWriter ¶
func NewHash32ChecksumWriter(h32 hash.Hash32) ChecksumWriter
func NewHashChecksumWriter ¶
func NewHashChecksumWriter(h hash.Hash) ChecksumWriter
type LocalFileEntity ¶
type LocalFileEntity struct { LocalFileMeta // contains filtered or unexported fields }
LocalFileEntity 校验本地文件
func GetFileSum ¶
func GetFileSum(localPath string, flag int) (lfc *LocalFileEntity, err error)
GetFileSum 获取文件的大小, md5, crc32
func NewLocalFileEntity ¶
func NewLocalFileEntity(localPath string) *LocalFileEntity
func NewLocalFileEntityWithBufSize ¶
func NewLocalFileEntityWithBufSize(localPath string, bufSize int) *LocalFileEntity
func (*LocalFileEntity) OpenPath ¶
func (lfc *LocalFileEntity) OpenPath() error
OpenPath 检查文件状态并获取文件的大小 (Length)
func (*LocalFileEntity) Sum ¶
func (lfc *LocalFileEntity) Sum(checkSumFlag int) (err error)
Sum 计算文件摘要值
type LocalFileMeta ¶
type LocalFileMeta struct { Path string `json:"path,omitempty"` // 本地路径 Length int64 `json:"length,omitempty"` // 文件大小 MD5 string `json:"md5,omitempty"` // 文件的 md5 CRC32 uint32 `json:"crc32,omitempty"` // 文件的 crc32 ModTime int64 `json:"modtime"` // 修改日期 // ParentFolderId 存储云盘的目录ID ParentFolderId string `json:"parent_folder_id,omitempty"` // UploadFileId 上传文件请求ID UploadFileId string `json:"upload_file_id,omitempty"` // FileUploadUrl 上传文件数据的URL路径 FileUploadUrl string `json:"file_upload_url,omitempty"` // FileCommitUrl 上传文件完成后确认路径 FileCommitUrl string `json:"file_commit_url,omitempty"` // FileDataExists 文件是否已存在云盘中,0-未存在,1-已存在 FileDataExists int `json:"file_data_exists,omitempty"` // 请求的X-Request-ID XRequestId string `json:"x_request_id,omitempty"` }
LocalFileMeta 本地文件元信息
func (*LocalFileMeta) CompleteAbsPath ¶
func (lfm *LocalFileMeta) CompleteAbsPath()
CompleteAbsPath 补齐绝对路径
func (*LocalFileMeta) EqualLengthMD5 ¶
func (lfm *LocalFileMeta) EqualLengthMD5(m *LocalFileMeta) bool
EqualLengthMD5 检测md5和大小是否相同