Documentation ¶
Index ¶
- Variables
- func GetClientTrace(traceMsg, metricPrefix, ruid string, tn *time.Time) *httptrace.ClientTrace
- type Client
- func (c *Client) CreateFeedWithManifest(request *feed.Request) (string, error)
- func (c *Client) Download(hash, path string) (*File, error)
- func (c *Client) DownloadDirectory(hash, path, destDir, credentials string) error
- func (c *Client) DownloadFile(hash, path, dest, credentials string) error
- func (c *Client) DownloadManifest(hash string) (*api.Manifest, bool, error)
- func (c *Client) DownloadRaw(hash string) (io.ReadCloser, bool, error)
- func (c *Client) GetFeedRequest(query *feed.Query, manifestAddressOrDomain string) (*feed.Request, error)
- func (c *Client) List(hash, prefix, credentials string) (*api.ManifestList, error)
- func (c *Client) MultipartUpload(hash string, uploader Uploader) (string, error)
- func (c *Client) QueryFeed(query *feed.Query, manifestAddressOrDomain string) (io.ReadCloser, error)
- func (c *Client) TarUpload(hash string, uploader Uploader, defaultPath string, toEncrypt bool) (string, error)
- func (c *Client) UpdateFeed(request *feed.Request) error
- func (c *Client) Upload(file *File, manifest string, toEncrypt bool) (string, error)
- func (c *Client) UploadDirectory(dir, defaultPath, manifest string, toEncrypt bool) (string, error)
- func (c *Client) UploadManifest(m *api.Manifest, toEncrypt bool) (string, error)
- func (c *Client) UploadRaw(r io.Reader, size int64, toEncrypt bool) (string, error)
- type DirectoryUploader
- type File
- type FileUploader
- type UploadFn
- type Uploader
- type UploaderFunc
Constants ¶
This section is empty.
Variables ¶
var ErrNoFeedUpdatesFound = errors.New("No updates found for this feed")
ErrNoFeedUpdatesFound is returned when Swarm cannot find updates of the given feed
var (
)Functions ¶
func GetClientTrace ¶
func GetClientTrace(traceMsg, metricPrefix, ruid string, tn *time.Time) *httptrace.ClientTrace
Types ¶
type Client ¶
type Client struct {
Gateway string
}
Client wraps interaction with a swarm HTTP gateway.
func (*Client) CreateFeedWithManifest ¶
CreateFeedWithManifest creates a feed manifest, initializing it with the provided data Returns the resulting feed manifest address that you can use to include in an ENS Resolver (setContent) or reference future updates (Client.UpdateFeed)
func (*Client) Download ¶
Download downloads a file with the given path from the swarm manifest with the given hash (i.e. it gets bzz:/<hash>/<path>)
func (*Client) DownloadDirectory ¶
DownloadDirectory downloads the files contained in a swarm manifest under the given path into a local directory (existing files will be overwritten)
func (*Client) DownloadFile ¶
DownloadFile downloads a single file into the destination directory if the manifest entry does not specify a file name - it will fallback to the hash of the file as a filename
func (*Client) DownloadManifest ¶
DownloadManifest downloads a swarm manifest
func (*Client) DownloadRaw ¶
DownloadRaw downloads raw data from swarm and it returns a ReadCloser and a bool whether the content was encrypted
func (*Client) GetFeedRequest ¶
func (c *Client) GetFeedRequest(query *feed.Query, manifestAddressOrDomain string) (*feed.Request, error)
GetFeedRequest returns a structure that describes the referenced feed status manifestAddressOrDomain is the address you obtained in CreateFeedWithManifest or an ENS domain whose Resolver points to that address
func (*Client) List ¶
func (c *Client) List(hash, prefix, credentials string) (*api.ManifestList, error)
List list files in a swarm manifest which have the given prefix, grouping common prefixes using "/" as a delimiter.
For example, if the manifest represents the following directory structure:
file1.txt file2.txt dir1/file3.txt dir1/dir2/file4.txt
Then:
- a prefix of "" would return [dir1/, file1.txt, file2.txt] - a prefix of "file" would return [file1.txt, file2.txt] - a prefix of "dir1/" would return [dir1/dir2/, dir1/file3.txt]
where entries ending with "/" are common prefixes.
func (*Client) MultipartUpload ¶
MultipartUpload uses the given Uploader to upload files to swarm as a multipart form, returning the resulting manifest hash
func (*Client) QueryFeed ¶
func (c *Client) QueryFeed(query *feed.Query, manifestAddressOrDomain string) (io.ReadCloser, error)
QueryFeed returns a byte stream with the raw content of the feed update manifestAddressOrDomain is the address you obtained in CreateFeedWithManifest or an ENS domain whose Resolver points to that address
func (*Client) TarUpload ¶
func (c *Client) TarUpload(hash string, uploader Uploader, defaultPath string, toEncrypt bool) (string, error)
TarUpload uses the given Uploader to upload files to swarm as a tar stream, returning the resulting manifest hash
func (*Client) UpdateFeed ¶
UpdateFeed allows you to set a new version of your content
func (*Client) Upload ¶
Upload uploads a file to swarm and either adds it to an existing manifest (if the manifest argument is non-empty) or creates a new manifest containing the file, returning the resulting manifest hash (the file will then be available at bzz:/<hash>/<path>)
func (*Client) UploadDirectory ¶
UploadDirectory uploads a directory tree to swarm and either adds the files to an existing manifest (if the manifest argument is non-empty) or creates a new manifest, returning the resulting manifest hash (files from the directory will then be available at bzz:/<hash>/path/to/file), with the file specified in defaultPath being uploaded to the root of the manifest (i.e. bzz:/<hash>/)
func (*Client) UploadManifest ¶
UploadManifest uploads the given manifest to swarm
type DirectoryUploader ¶
type DirectoryUploader struct {
Dir string
}
DirectoryUploader uploads all files in a directory, optionally uploading a file to the default path
func (*DirectoryUploader) Upload ¶
func (d *DirectoryUploader) Upload(upload UploadFn) error
Upload performs the upload of the directory and default path
type File ¶
type File struct { io.ReadCloser api.ManifestEntry }
File represents a file in a swarm manifest and is used for uploading and downloading content to and from swarm
type FileUploader ¶
type FileUploader struct {
File *File
}
FileUploader uploads a single file
func (*FileUploader) Upload ¶
func (f *FileUploader) Upload(upload UploadFn) error
Upload performs the upload of the file
type UploadFn ¶
UploadFn is the type of function passed to an Uploader to perform the upload of a single file (for example, a directory uploader would call a provided UploadFn for each file in the directory tree)
type UploaderFunc ¶
func (UploaderFunc) Upload ¶
func (u UploaderFunc) Upload(upload UploadFn) error