Documentation
¶
Overview ¶
gcsfs implements io/fs for GCS, adding writability.
Index ¶
- func DirFS(dir string) fs.FS
- func FromURL(ctx context.Context, client *storage.Client, base string) (fs.FS, error)
- func NewFS(ctx context.Context, client *storage.Client, bucket string) fs.FS
- func WriteFile(fsys fs.FS, filename string, contents []byte) error
- type CreateFS
- type GCSFile
- type WriterFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DirFS ¶
DirFS is a variant of os.DirFS that supports file creation and is a suitable test fake for the GCS FS.
func FromURL ¶
FromURL creates a new FS from a file:// or gs:// URL. client is only used for gs:// URLs and can be nil otherwise.
func NewFS ¶
NewFS creates a new fs.FS that uses ctx for all of its operations. Creating a new FS does not access the network, so they can be created and destroyed per-context.
Once the context has finished, all objects created by this FS should be considered invalid. In particular, Writers and Readers will be canceled.
Types ¶
type CreateFS ¶
type CreateFS interface { fs.FS Create(string) (WriterFile, error) }
CreateFS is an fs.FS that supports creating writable files.
type GCSFile ¶
type GCSFile struct {
// contains filtered or unexported fields
}
GCSFile implements fs.File for GCS. It is also a WriteFile.
func (*GCSFile) Stat ¶
Stats the file. The returned FileInfo exposes *storage.ObjectAttrs as its Sys() result.
func (*GCSFile) Write ¶
Write writes to the GCS object associated with this File.
A new object will be created unless an object with this name already exists. Otherwise any previous object with the same name will be replaced. The object will not be available (and any previous object will remain) until Close has been called.
type WriterFile ¶
WriterFile is an fs.File that can be written to. The behavior of writing and reading the same file is undefined.