Go library for programmatic uploads to the Sharify platform.
Sharify-Go works alongside other Sharify components:
- Canvas: Serves uploaded content to end users
- Spine: Web panel backend for user/content management
- Zephyr: Core upload API and storage service
- Sharify-Desktop: Cross-platform desktop app
Note: This project is not actively maintained and should not be used in a production environment.
Sharify-Go is the official Go SDK for the Sharify platform, built with the functional options pattern seen in cloudflare-go.
It provides type-safe upload operations with built-in authentication and multipart form handling.
- Upload files, images, pastes, and urls (for redirects)
- Support for both authenticated (with API token) and anonymous uploads
- Type-safe upload options (custom domains, expiration, secrets)
- List and manage existing uploads (authenticated users only)
- Automatic content-type detection and proper multipart encoding
package main
import (
"fmt"
"github.com/sharify-labs/sharify-go"
"time"
)
func main() {
api := sharify.New()
// Upload a local file
image, err := api.UploadLocalFile("photo.png")
if err != nil {
panic(err)
}
fmt.Printf("Image URL: %s\n", image.URL)
// Shorten a URL
link, err := api.ShortenLink("https://google.com",
sharify.SetDuration(24*time.Hour))
if err != nil {
panic(err)
}
fmt.Printf("Short URL: %s\n", link.URL)
// Upload text paste
paste, err := api.UploadPaste("My code snippet",
sharify.SetDuration(72*time.Hour))
if err != nil {
panic(err)
}
fmt.Printf("Paste URL: %s\n", paste.URL)
}
package main
import (
"github.com/sharify-labs/sharify-go"
"time"
)
func main() {
token := "sfy_abc123_def456..."
api := sharify.New(
sharify.AuthToken(token),
sharify.WithTimeout(30*time.Second),
sharify.UserAgent("my-project/1.2.3"),
)
// Upload with custom domain and expiration
image, err := api.UploadLocalFile("image.png",
sharify.SetDomain("i.mysite.com"),
sharify.SetSecret("my-custom-path"),
sharify.SetExpiration(time.Date(2024, 12, 31, 23, 59, 59, 0, time.UTC)),
)
if err != nil {
panic(err)
}
// List uploads with filtering
uploads, err := api.ListUploads(
sharify.SortBy(sharify.SortByDate, sharify.OrderDescending),
sharify.IncludeTypes(sharify.ImageT, sharify.FileT),
sharify.IncludeHosts("i.mysite.com"),
sharify.SetLimit(50),
sharify.SetPage(1),
)
if err != nil {
panic(err)
}
// Edit upload metadata
err = api.EditUpload(image.StorageKey,
sharify.EditTitle("My Updated Title"),
sharify.EditDuration(168*time.Hour), // 1 week
)
if err != nil {
panic(err)
}
// Delete uploads
err = api.DeleteUploads(image.StorageKey)
if err != nil {
panic(err)
}
}
sharify.ImageT // PNG, JPEG, GIF, WebP files
sharify.FileT // Any other binary files
sharify.PasteT // Plain text content
sharify.RedirectT // URL shortening
// Content options
sharify.SetTitle("My Upload")
sharify.SetSecret("custom-path") // Custom URL path
sharify.SetDomain("files.mysite.com") // Custom domain (auth required)
// Expiration options (choose one)
sharify.SetDuration(72*time.Hour) // Hours until expiration
sharify.SetExpiration(futureTime) // Specific expiration datetime
// Pagination
sharify.SetLimit(50) // Max 100 per request
sharify.SetPage(2) // Page number
// Content filtering
sharify.IncludeTypes(sharify.ImageT, sharify.FileT)
sharify.IncludeHosts("i.mysite.com", "files.mysite.com")
sharify.IncludeMimes("image/jpeg", "text/plain")
sharify.IncludeSecrets("secret1", "secret2")
// Sorting
sharify.SortBy(sharify.SortByDate, sharify.OrderDescending)
sharify.SortBy(sharify.SortBySize, sharify.OrderAscending)
sharify.EditTitle("New Title")
sharify.EditDuration(48*time.Hour)
sharify.EditExpiration(newExpirationTime)
The SDK automatically handles authentication based on whether a token is provided:
Mode | Limitations |
---|---|
Anonymous | Max 30 days expiration, no custom domains |
Authenticated | Full access to all features |
// Anonymous (limited features)
api := sharify.New()
// Authenticated (full features)
api := sharify.New(sharify.AuthToken("sfy_abc123_def456..."))