The catbox
package provides functions to upload files to CatBox and LitterBox, allowing for easy file sharing and storage through their APIs.
- Upload files to CatBox: Use
UploadFile
to upload a file to a specific user account. - Upload files to LitterBox: Use
UploadToLitterBox
to upload files with a specified storage duration.
- deleteFiles(files, userHash) - Delete files from CatBox with a specific user account.
- uploadAlbum(files, title, description, userHash): Create an album with the uploaded files.
- deleteAlbum, editAlbum, createAlbum ... etc
To use the catbox
package in your Go project, you can import it directly:
import "github.com/AshokShau/catbox"
Examples of uploading files to CatBox and LitterBox are shown below.
RealTime Example: here
fileBuffer := bytes.NewBuffer(yourFileBytes)
fileName := "example.txt"
timeout := 10 * time.Second
userHash := "" // optional
url, err := catbox.UploadFile(fileBuffer, fileName, timeout, userHash)
if err != nil {
log.Fatalf("Upload failed: %v", err)
}
fmt.Println("Uploaded to CatBox:", url)
fileBuffer := bytes.NewBuffer(yourFileBytes)
fileName := "example.txt"
duration := "24h" // Options: '1h', '12h', '24h', '72h', '1w'
timeout := 10 * time.Second
url, err := catbox.UploadToLitterBox(fileBuffer, fileName, duration, timeout)
if err != nil {
log.Fatalf("Upload failed: %v", err)
}
fmt.Println("Uploaded to LitterBox:", url)
fileBuffer
: A*bytes.Buffer
containing the file content.fileName
: The name of the file to be uploaded.timeout
: Duration to wait for the server response.userHash
: Optional parameter to upload files to a specific user account.
fileBuffer
: A*bytes.Buffer
containing the file content.fileName
: The name of the file to be uploaded.duration
: Duration for which the file should be stored on the server (e.g., '1h', '12h', '24h', '72h', '1w').timeout
: Duration to wait for the server response.
Both functions return an error if the upload fails. Common reasons include:
- Network issues
- Invalid parameters
- Non-200 HTTP responses
This project is licensed under the MIT License - see the LICENSE file for details.