The package returns structured responses for uploads:
type UploadResponse struct {
Status string // "success"
URL string // Public URL of the uploaded file
Metadata Metadata // File details
}
type Metadata struct {
OriginalName string // Original file name
FileType string // MIME type
FileSize int64 // Size in bytes
UploadTime string // ISO8601 timestamp
}
type ErrorResponse struct {
Status string // "error"
Message string // Error message
}
This package provides a reusable Go client for uploading files to the Ekilie Bucket API. It handles file validation, multipart uploads, and response parsing.
- Simple client for Ekilie Bucket API
- File type and size validation
- Multipart file upload
- Structured response and error handling
You can use Go modules to install the package directly:
go get github.com/ekilie/[email protected]
Or clone the repository:
git clone https://github.com/ekilie/bucket-go.git
cd bucket-go
go mod tidy
This package uses semantic versioning. To use a specific release, specify the tag (e.g. @v1.0.0) with go get.
import "github.com/ekilie/bucket-go/client"
apiKey := "your-api-key"
c := client.NewClient(apiKey)import (
"github.com/ekilie/bucket-go/store"
"github.com/ekilie/bucket-go/client"
)
resp, err := store.UploadFile(c, "/path/to/file.jpg")
if err != nil {
// handle error
}
fmt.Println("File URL:", resp.URL)
fmt.Printf("Metadata: %+v\n", resp.Metadata)See main.go for a complete demo:
package main
import (
"fmt"
"os"
"github.com/ekilie/bucket-go/client"
"github.com/ekilie/bucket-go/store"
)
func main() {
apiKey := "your-api-key"
filePath := "sample.jpg"
c := client.NewClient(apiKey)
resp, err := store.UploadFile(c, filePath)
if err != nil {
fmt.Fprintf(os.Stderr, "Upload failed: %v\n", err)
os.Exit(1)
}
fmt.Printf("File uploaded successfully! URL: %s\n", resp.URL)
fmt.Printf("Metadata: %+v\n", resp.Metadata)
}client.NewClient(apiKey string, baseURL ...string) *Client- Create a new API clientstore.UploadFile(c *client.Client, filePath string) (*model.UploadResponse, error)- Upload a file
- Maximum file size: 100MB
- Allowed extensions: jpg, jpeg, png, gif, webp, svg, pdf, txt, doc, docx, xls, xlsx, ppt, pptx, zip, rar, tar, gz, json, xml
MIT
ekilie bucket go client