Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Error
- ./knoxite -r backblaze://49979f5abff9:001ac045eb46758d123dbab9d487aa32fb6e291ff8@backblaze.com/KnoxiteTestRepo -p "123" repo init
- Creating repository at backblaze://49979f5abff9:001ac045eb46758d123dbab9d487aa32fb6e291ff8@backblaze.com/KnoxiteTestRepo failed: Invalid repository url specified
- // In backend.go
- ..
- case "dropbox":
- return NewStorageDropbox(*u), nil
- case "backblaze":
- return NewStorageBackblaze(*u)
- ....
- // In storage_backblaze.go
- func NewStorageBackblaze(URL url.URL) (*StorageBackblaze, error) {
- // Checking username and password
- if URL.User.Username() == "" {
- return &StorageBackblaze{}, nil
- }
- pw, pwexist := URL.User.Password()
- if pwexist {
- return &StorageBackblaze{}, ErrInvalidPassword
- }
- // Creating a new Client for accessing the B2 API
- cl, err := backblaze.NewB2(backblaze.Credentials{
- AccountID: URL.User.Username(),
- ApplicationKey: pw,
- })
- if err != nil {
- return &StorageBackblaze{}, err
- }
- // Creating the bucket
- bucket, err := cl.CreateBucket(URL.Path, backblaze.AllPrivate)
- if err != nil {
- return &StorageBackblaze{}, err
- }
- return &StorageBackblaze{
- url: URL,
- chunkFile: URL.Path + "_chunks",
- snapshotFile: URL.Path + "_snapshots",
- repositoryFile: URL.Path + "_repository",
- bucket: bucket,
- backblaze: cl,
- }, nil
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement