Documentation
¶
Overview ¶
Package icpaybucket is a minimal client for the ICPay Bucket canister — on-chain encrypted file storage on the Internet Computer.
Index ¶
- Constants
- func PublicFileURL(canisterID, bucketName, path string) string
- type ApiResult
- type Client
- func (c *Client) DeleteFile(bucketID, path, apiKey string) (resultUnit, error)
- func (c *Client) DownloadFile(bucketID, path string) (resultBlob, error)
- func (c *Client) GetPublicFileURL(bucketID, path string) (resultString, error)
- func (c *Client) ListFiles(bucketID string, page, pageSize uint64) (resultFileList, error)
- func (c *Client) PublicURL(bucketName, path string) string
- func (c *Client) UploadFile(bucketID, path string, data []byte, contentType string, apiKey string) (resultFileID, error)
- type ClientOptions
- type FileListPage
- type FilePublic
Constants ¶
const DefaultCanisterID = "6vbhm-nqaaa-aaaan-q6muq-cai"
DefaultCanisterID is the live ICPay backend canister on mainnet.
const SingleMaxBytes = 1_850_000
SingleMaxBytes is the ceiling for a single uploadFile call (~1.85 MB).
Variables ¶
This section is empty.
Functions ¶
func PublicFileURL ¶
PublicFileURL builds the raw HTTP gateway URL for a public file. No canister call is involved — this is the URL served directly by the gateway.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the ICPay bucket canister.
Writes (upload/delete) are authorized by a bucket API key or by an Internet Identity. Reads (list/download/publicUrl) work for any caller on a public bucket.
func NewClient ¶
func NewClient(options ClientOptions) (*Client, error)
NewClient creates a Client. An anonymous caller is used unless an identity is supplied; the API key (when set) authorizes writes as the bucket owner.
func (*Client) DeleteFile ¶
DeleteFile removes a file. Authorized by the API key.
func (*Client) DownloadFile ¶
DownloadFile returns file bytes (public + private buckets).
func (*Client) GetPublicFileURL ¶
GetPublicFileURL returns the canister-provided CDN URL for a file.
func (*Client) ListFiles ¶
ListFiles returns a paginated file list for a bucket. Public buckets allow any caller.
type ClientOptions ¶
type ClientOptions struct {
// APIKey authorizes writes without an identity.
APIKey string
// CanisterID overrides the default ICPay canister.
CanisterID string
// Host overrides the IC host (default https://icp0.io, mainnet).
Host string
// Identity overrides the anonymous caller used for updates.
Identity identity.Identity
}
ClientOptions configures a Client.
type FileListPage ¶
type FileListPage struct {
Items []FilePublic `ic:"items"`
Total idl.Nat `ic:"total"`
Page idl.Nat `ic:"page"`
PageSize idl.Nat `ic:"pageSize"`
}
FileListPage is the canister FileListPage record.