Documentation
¶
Index ¶
- Constants
- Variables
- func UploadPart(fupr *b2api.GetFileUploadPartResponse, up *Upload, p *UploaderPart, ...) (*b2api.UploadPartResponse, error)
- func UploaderDir(bucketName string) string
- type Cloud
- func (c *Cloud) AuthAccount()
- func (c *Cloud) CancelLargeFile(fileId string) (*b2api.CanxUpLgFileResp, errs.Error)
- func (c *Cloud) CreateBucket(bucketName string, bucketType b2api.BucketType, ...) (*b2api.CreateBucketResp, errs.Error)
- func (c *Cloud) CreateKey(keyName, keyBucket string, capabilities []string) (*b2api.CreateKeyResp, errs.Error)
- func (c *Cloud) DeleteBucket(bucketId string) (*b2api.DeleteBucketResp, errs.Error)
- func (c *Cloud) DeleteFile(fileName, fileID string) (*b2api.DeleteFileVersionResponse, errs.Error)
- func (c *Cloud) DeleteKey(keyId string) (*b2api.DeleteKeyResp, errs.Error)
- func (c *Cloud) DownloadByID(fileID, byteRange string) (map[string]interface{}, errs.Error)
- func (c *Cloud) DownloadByName(bucketName, fileName string) (map[string]interface{}, errs.Error)
- func (c *Cloud) FinishLargeFileUpload(fileId string, sha1Array []string) (*b2api.FinishUpLgFileResp, errs.Error)
- func (c *Cloud) GetDownloadAuth(bucketID, filenamePrefix string, validDurationInSeconds int64) (*b2api.DownloadAuthResponse, errs.Error)
- func (c *Cloud) GetFileInfo(fileID string) (*b2api.GetFileInfoResponse, errs.Error)
- func (c *Cloud) GetUploadPartURL(fileID string) (*b2api.GetFileUploadPartResponse, errs.Error)
- func (c *Cloud) HideFile(bucketId, fileName string) (*b2api.HideFileResponse, errs.Error)
- func (c *Cloud) ListBuckets(bucketId, bucketName string, bucketType []b2api.BucketType) (*b2api.ListBucketsResp, errs.Error)
- func (c *Cloud) ListFileVersions(bucketId, fileName, startFileName, startFileID string, qty int) (*b2api.ListFileVersionsResponse, errs.Error)
- func (c *Cloud) ListFiles(bucketId, filename, startFileName string, qty int) (*b2api.ListFilesResponse, errs.Error)
- func (c *Cloud) ListKeys() (*b2api.KeysResp, errs.Error)
- func (c *Cloud) ListPartsURL(fileID string, startPartNo, maxPartCount int64) (*b2api.ListPartsResponse, errs.Error)
- func (c *Cloud) ListUnfinishedLargeFiles(bucketID string) (*b2api.ListUnfinishedLargeFilesResponse, errs.Error)
- func (c *Cloud) MultipartDownloadById(fileID, localFilePath, fileNameOverride string) (string, error)
- func (c *Cloud) SendParts(up *Upload) (bool, error)
- func (c *Cloud) StartLargeFile(bucketID, fileInfo string, up *Upload) (*b2api.StartLargeFileResponse, errs.Error)
- func (c *Cloud) UpdateBucket(bucketId string, bucketType b2api.BucketType, ...) (*b2api.CreateBucketResp, errs.Error)
- func (c *Cloud) UploadFile(bucketId string, up *Upload) (*b2api.UploadResp, errs.Error)
- func (c *Cloud) UploadURL(bucketId string) (*b2api.UploadURLResp, errs.Error)
- func (c *Cloud) UploadVirtualFile(bucketId, fname string, data []byte, lastMod int64) (*b2api.UploadResp, errs.Error)
- type Rtnd
- type Upload
- func (u *Upload) Available() bool
- func (u *Upload) Completed() bool
- func (u *Upload) ComputePartTotal() error
- func (u *Upload) Process(c *Cloud) (string, error)
- func (u *Upload) SetupPartSizes(fileID string)
- func (u *Upload) UpdateEtag(partID int, appName, tag string)
- func (u *Upload) ValidateOverMinPartSize() bool
- func (u *Upload) ValidateSize() bool
- func (u *Upload) WriteOutFileData2Upload(app string)
- type UploaderPart
Constants ¶
const ( AppFolderName = ".cloudstore" // UploadFolder exported folder name UploadFolder = "upload" MaxAuthTry = 1000 )
const ( // MinPartSize in MB MinPartSize = 6 // MinParts count size MinParts = 2 // MaxUploadTB size in TB MaxUploadTB = 10 DownSplitThresh = 200000000 )
const DownloadFileChunk = 10 * (1 << 20)
Variables ¶
var AuthCounter = 0
var (
//MaxPerSessionUploadPerPart sessions
MaxPerSessionUploadPerPart = 3
)
Functions ¶
func UploadPart ¶
func UploadPart(fupr *b2api.GetFileUploadPartResponse, up *Upload, p *UploaderPart, fo *os.File, meta file.Meta) (*b2api.UploadPartResponse, error)
Types ¶
type Cloud ¶
type Cloud struct { AuthConfig b2api.AuthConfig AuthResponse *b2api.AuthorizationResp }
func CloudStore ¶
func (*Cloud) AuthAccount ¶
func (c *Cloud) AuthAccount()
func (*Cloud) CancelLargeFile ¶
CancelLargeFile cancel large file upload process
func (*Cloud) CreateBucket ¶
func (c *Cloud) CreateBucket(bucketName string, bucketType b2api.BucketType, bucketInfo map[string]interface{}, corsRules []b2api.CorsRules, lifeCycleRules []b2api.LifecycleRules) (*b2api.CreateBucketResp, errs.Error)
CreateBucket create a bucket on account
func (*Cloud) CreateKey ¶
func (c *Cloud) CreateKey(keyName, keyBucket string, capabilities []string) (*b2api.CreateKeyResp, errs.Error)
CreateKey create account key
func (*Cloud) DeleteBucket ¶
DeleteBucket remove from account
func (*Cloud) DeleteFile ¶
DeleteFile deletes file version by file id
func (*Cloud) DownloadByID ¶
DownloadByID downloads file by id
In map:
body - content of file Content-Length Content-Type X-Bz-File-Id X-Bz-File-Name X-Bz-Content-Sha1 X-Bz-Info-author X-Bz-Upload-Timestamp Cache-Control : max-age (only); inherited from Bucket Info
PLUS:
X-Bz-Info-* headers for any custom file info during upload
func (*Cloud) DownloadByName ¶
GetDownloadAuth required prior to download
In map:
body - content of file Content-Length Content-Type X-Bz-File-Id X-Bz-File-Name X-Bz-Content-Sha1 X-Bz-Info-author X-Bz-Upload-Timestamp Cache-Control : max-age (only); inherited from Bucket Info
PLUS:
X-Bz-Info-* headers for any custom file info during upload
func (*Cloud) FinishLargeFileUpload ¶
func (c *Cloud) FinishLargeFileUpload(fileId string, sha1Array []string) (*b2api.FinishUpLgFileResp, errs.Error)
FinishLargeFileUpload call complete on large upload
func (*Cloud) GetDownloadAuth ¶
func (c *Cloud) GetDownloadAuth(bucketID, filenamePrefix string, validDurationInSeconds int64) (*b2api.DownloadAuthResponse, errs.Error)
GetDownloadAuth required prior to download
func (*Cloud) GetFileInfo ¶
GetFileInfo provides file information
func (*Cloud) GetUploadPartURL ¶
func (*Cloud) ListBuckets ¶
func (c *Cloud) ListBuckets(bucketId, bucketName string, bucketType []b2api.BucketType) (*b2api.ListBucketsResp, errs.Error)
ListBuckets list out buckets for account
func (*Cloud) ListFileVersions ¶
func (c *Cloud) ListFileVersions(bucketId, fileName, startFileName, startFileID string, qty int) (*b2api.ListFileVersionsResponse, errs.Error)
ListFileVersions lists out all versions of file
func (*Cloud) ListFiles ¶
func (c *Cloud) ListFiles(bucketId, filename, startFileName string, qty int) (*b2api.ListFilesResponse, errs.Error)
ListFiles list files by name or all in bucket
func (*Cloud) ListPartsURL ¶
func (*Cloud) ListUnfinishedLargeFiles ¶
func (c *Cloud) ListUnfinishedLargeFiles(bucketID string) (*b2api.ListUnfinishedLargeFilesResponse, errs.Error)
ListUnfinishLargeFiles show unfinished large file uploads
func (*Cloud) MultipartDownloadById ¶
func (*Cloud) StartLargeFile ¶
func (c *Cloud) StartLargeFile(bucketID, fileInfo string, up *Upload) (*b2api.StartLargeFileResponse, errs.Error)
StartLargeFile create initial start call
func (*Cloud) UpdateBucket ¶
func (c *Cloud) UpdateBucket(bucketId string, bucketType b2api.BucketType, bucketInfo map[string]interface{}, corsRules []b2api.CorsRules, lifeCycleRules []b2api.LifecycleRules) (*b2api.CreateBucketResp, errs.Error)
UpdateBucket update bucket properties
func (*Cloud) UploadFile ¶
UploadFile file name and info must fit in 7k byte limit,
the file to be uploaded is the message body and is not encoded in any way. it's not URL encoded, it's not MIME encoded
func (*Cloud) UploadVirtualFile ¶
type Upload ¶
type Upload struct { AppName string `json:"-"` Bucket string `json:"bucket"` Filepath string `json:"filepath"` OverridePath string `json:"override_path"` UploadID string `json:"uploadid"` File file.File `json:"-"` FileID string `json:"fileId"` Parts []*UploaderPart `json:"parts"` TotalPartsCount uint64 `json:"total_parts_count"` // contains filtered or unexported fields }
Upload struct
func NewUploader ¶
New create upload object
func (*Upload) ComputePartTotal ¶
ComputePartTotal compute total parts
func (*Upload) SetupPartSizes ¶
SetupPartSizes determine part sizes Pass in part count Pass in data on each part size and status i.e. completed or not
func (*Upload) UpdateEtag ¶
UpdateEtag update each etag
func (*Upload) ValidateOverMinPartSize ¶
ValidateOverMinPartSize check size
func (*Upload) WriteOutFileData2Upload ¶
WriteOut write out upload info
type UploaderPart ¶
type UploaderPart struct { Size int64 `json:"size"` PartID uint64 `json:"part"` Start int64 `json:"start"` End int64 `json:"end"` Etag string `json:"etag"` }
******************************************************* UploaderPart struct
func NewUploaderPart ¶
func NewUploaderPart(part uint64, start, end, size int64) *UploaderPart
NewUploaderPart create uploader part