func New(ctx context.Context, opt *Options) (blob.Storage, error) {
	if opt.FolderID == "" {
		return nil, errors.New("folder-id must be specified")
	}

	service, err := CreateDriveService(ctx, opt)
	if err != nil {
		return nil, err
	}

	gdrive := &gdriveStorage{
		Options:     *opt,
		client:      service.Files,
		about:       service.About,
		folderID:    opt.FolderID,
		fileIDCache: newFileIDCache(),
	}

	// verify Drive connection is functional by listing blobs in a bucket, which will fail if the bucket
	// does not exist. We list with a prefix that will not exist, to avoid iterating through any objects.
	nonExistentPrefix := fmt.Sprintf("kopia-gdrive-storage-initializing-%v", clock.Now().UnixNano())
	err = gdrive.ListBlobs(ctx, blob.ID(nonExistentPrefix), func(md blob.Metadata) error {
		return nil
	})

	if err != nil {
		return nil, errors.Wrap(err, "unable to list from the folder")
	}

	return retrying.NewWrapper(gdrive), nil
}
// New creates new Google Drive-backed storage with specified options:
//
// - the 'folderID' field is required and all other parameters are optional.
//
// By default the connection reuses credentials managed by (https://cloud.google.com/sdk/),
// but this can be disabled by setting IgnoreDefaultCredentials to true.
New creates new Google Drive-backed storage with specified options.

- the 'folderID' field is required and all other parameters are optional.

By default the connection reuses credentials managed by ,
but this can be disabled by setting IgnoreDefaultCredentials to true.
// New creates new Google Drive - backed storage with specified options : // // - the ' folderID ' field is required and all other parameters are optional . // // By default the connection reuses credentials managed by ( https : // cloud . google . com / sdk / ) // but this can be disabled by setting IgnoreDefaultCredentials to true .
func New(ctx context.Context, opt *Options) (blob.Storage, error) {
	if opt.FolderID == "" {
		return nil, errors.New("folder-id must be specified")
	}
	service, err := CreateDriveService(ctx, opt)
	if err != nil {
		return nil, err
	}
	gdrive := &gdriveStorage{
		Options:     *opt,
		client:      service.Files,
		about:       service.About,
		folderID:    opt.FolderID,
		fileIDCache: newFileIDCache(),
	}
	nonExistentPrefix := fmt.Sprintf("kopia-gdrive-storage-initializing-%v", clock.Now().UnixNano())
	err = gdrive.ListBlobs(ctx, blob.ID(nonExistentPrefix), func(md blob.Metadata) error {
		return nil
	})
	if err != nil {
		return nil, errors.Wrap(err, "unable to list from the folder")
	}
	return retrying.NewWrapper(gdrive), nil
}
func New ( ctx context . Context , opt * Options ) ( blob . Storage , error ) { if opt . FolderID == " " { return nil , errors . New ( " " ) } service , err := CreateDriveService ( ctx , opt ) if err != nil { return nil , err } gdrive := & gdriveStorage { Options : * opt , client : service . Files , about : service . About , folderID : opt . FolderID , fileIDCache : newFileIDCache ( ) , } nonExistentPrefix := fmt . Sprintf ( " " , clock . Now ( ) . UnixNano ( ) ) err = gdrive . ListBlobs ( ctx , blob . ID ( nonExistentPrefix ) , func ( md blob . Metadata ) error { return nil } ) if err != nil { return nil , errors . Wrap ( err , " " ) } return retrying . NewWrapper ( gdrive ) , nil }
New creates new Google Drive-backed storage with specified options.
New creates new Google Drive - backed storage with specified options .
// verify Drive connection is functional by listing blobs in a bucket, which will fail if the bucket // does not exist. We list with a prefix that will not exist, to avoid iterating through any objects.