Esempio n. 1
0
func TempFileBucket(name string) bucket.Bucket {
	dir := filepath.Join(TempDir, name)
	b, err := bucket.NewFileBucket(dir)
	if err != nil {
		panic(err)
	}
	return b
}
Esempio n. 2
0
func openBucket(bucketPath string) (bucket.Bucket, error) {
	file, err := os.Open(bucketPath)
	if err != nil {
		return nil, err
	}
	fi, err := file.Stat()
	if err != nil {
		return nil, err
	}

	if fi.IsDir() {
		return bucket.NewFileBucket(bucketPath)
	} else {
		b, err := bucket.NewS3BucketFromFile(bucketPath)
		if err != nil {
			return nil, fmt.Errorf("bucket.NewS3BucketFromFile: %s", err)
		}
		return b, nil
	}
}