Example #1
0
// Create opens the file at path for writing, creating the file if it doesn't
// exist and truncating it otherwise.
func (fs *S3FS) Create(path string) (io.WriteCloser, error) {
	wc, err := s3util.Create(fs.url(path), nil, fs.config)
	if err != nil {
		return nil, &os.PathError{Op: "create", Path: fs.url(path), Err: err}
	}
	return wc, nil
}
Example #2
0
func (c *Cache) Set(key string, resp []byte) {
	w, err := s3util.Create(c.url(key), nil, &c.Config)
	if err != nil {
		log.Printf("s3util.Create failed: %s", err)
		return
	}
	defer w.Close()
	if c.Gzip {
		w = gzip.NewWriter(w)
		defer w.Close()
	}
	_, err = w.Write(resp)
	if err != nil {
		log.Printf("s3cache.Set failed: %s", err)
	}
}