Overview
Go Files SDK gives Go services one storage client for S3, R2, Vercel Blob, local files, memory storage, S3-compatible buckets, and UploadThing.
What is Go Files SDK?
Go Files SDK is a storage library for Go applications that need one call shape across object storage providers. You create a files.Client with an adapter, then use the same methods for upload, download, metadata, listing, signed URLs, bulk operations, and transfers.
package main
import (
"context"
"fmt"
files "github.com/cersho/gofiles-sdk"
"github.com/cersho/gofiles-sdk/providers/memory"
)
func main() {
ctx := context.Background()
client := files.MustNew(files.Options{
Adapter: memory.New(memory.Options{}),
})
_, err := client.Upload(ctx, "invoices/june.txt", files.StringBody("paid"), files.UploadOptions{})
if err != nil {
panic(err)
}
ok, err := client.Exists(ctx, "invoices/june.txt", files.OperationOptions{})
if err != nil {
panic(err)
}
fmt.Println(ok)
// Output: true
}Why use it?
Every storage provider has a different client, request type, error model, and signing API. Go Files SDK keeps provider-specific code at the adapter boundary, so the rest of your service can stay focused on keys, bodies, metadata, and storage results.
- Unified methods:
Upload,Download,Head,Exists,Delete,Copy,Move,List,ListAll,Search,URL, andSignedUploadURL. - Provider adapters: use
providers/s3,providers/r2,providers/fs,providers/memory,providers/s3compatible,providers/digitaloceanspaces,providers/uploadthing, orproviders/vercelblob. - Go-native bodies: use
StringBody,BytesBody,ReaderBody,FileBody, orNewBodyFromReadCloser. - Normalized errors: catch
*files.Errorand branch on codes such asNotFound,Unauthorized,Conflict,ReadOnly, andProvider. - Escape hatch: call
client.Raw()or adapter-specific methods when you need provider-native behavior.
Next steps
- Installation - add the module and choose a provider.
- Usage - create a client and call the core methods.
- Adapters - configure each supported backend.
- API - read the public Go surface.