meowbox

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2026 License: MIT Imports: 9 Imported by: 0

README

meowbox (Go)

Permanent file hosting — files never expire. A Go library for uploading files to MeowBox.


Installation

In Go, GitHub itself acts as the package registry. Simply run this in your project:

go get github.com/Badmunda05/meowbox

Then import it in your code:

import "github.com/Badmunda05/meowbox"

Note: The GitHub repository must be public and the module path must match.


Usage

Single file upload
package main

import (
    "bytes"
    "fmt"
    "os"
    "time"

    "github.com/Badmunda05/meowbox"
)

func main() {
    file, err := os.Open("photo.jpg")
    if err != nil {
        fmt.Println("Error opening file:", err)
        return
    }
    defer file.Close()

    var buf bytes.Buffer
    buf.ReadFrom(file)

    url, err := meowbox.UploadFile(&buf, "photo.jpg", 30*time.Second)
    if err != nil {
        fmt.Println("Upload failed:", err)
        return
    }
    fmt.Println("Uploaded:", url)
    // https://files.tgvibes.online/AbCdEfGh.jpg
}
Multi-file upload
entries := []meowbox.FileEntry{
    {Buffer: &buf1, FileName: "file1.jpg"},
    {Buffer: &buf2, FileName: "file2.mp4"},
}

urls, err := meowbox.UploadFiles(entries, 30*time.Second)
if err != nil {
    fmt.Println("Upload failed:", err)
    return
}
for _, u := range urls {
    fmt.Println(u)
}
Run the example
git clone https://github.com/Badmunda05/meowbox
cd meowbox/example
go run main.go photo.jpg
# Multiple files:
go run main.go file1.jpg file2.mp4

Users can then install it with:

go get github.com/Badmunda05/meowbox@v1.0.0
# or always get the latest:
go get github.com/Badmunda05/meowbox

API Reference

Function Description
UploadFile(buf, fileName, timeout) Uploads a single file, returns the direct URL
UploadFiles([]FileEntry, timeout) Uploads multiple files, returns a slice of URLs
Types
type FileEntry struct {
    Buffer   *bytes.Buffer
    FileName string
}

Error Handling

url, err := meowbox.UploadFile(&buf, "photo.jpg", 30*time.Second)
if err != nil {
    // Possible errors:
    // - "upload request timed out after N seconds"
    // - "rate limit hit — too many requests, try again later"
    // - "upload failed: <server message>"
    // - "HTTP error occurred: ..."
    fmt.Println("Upload failed:", err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UploadFile

func UploadFile(fileBuffer *bytes.Buffer, fileName string, timeout time.Duration) (string, error)

UploadFile uploads a single file and returns the direct URL.

func UploadFiles

func UploadFiles(files []FileEntry, timeout time.Duration) ([]string, error)

UploadFiles uploads multiple files and returns all URLs.

Types

type FileEntry

type FileEntry struct {
	Buffer   *bytes.Buffer
	FileName string
}

FileEntry holds file data for multi-upload.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL