Help us shape the future of Go! Take the 2026 Go Developer Survey

asset

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: BSD-3-Clause Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dependencies

type Dependencies struct {
	archive.ArchiveFactory
}

type FileAsset

type FileAsset struct {
	// contains filtered or unexported fields
}

Represents a publication stored as a file on the local file system.

func File

func File(uri url.URL) *FileAsset

func FileWithMediaType

func FileWithMediaType(uri url.URL, mediatype *mediatype.MediaType) *FileAsset

Creates a FileAsset from a File and an optional media type, when known.

func FileWithMediaTypeHint

func FileWithMediaTypeHint(uri url.URL, mediatypeHint string) *FileAsset

Creates a FileAsset from a File and an optional media type hint. Providing a media type hint will improve performances when sniffing the media type.

func (*FileAsset) CreateFetcher

func (a *FileAsset) CreateFetcher(ctx context.Context, dependencies Dependencies, credentials string) (fetcher.Fetcher, error)

CreateFetcher implements PublicationAsset

func (*FileAsset) CreateRelativeFetcher added in v0.15.0

func (a *FileAsset) CreateRelativeFetcher(ctx context.Context, root url.URL) (fetcher.Fetcher, error)

CreateRelativeFetcher implements RelativePublicationAsset

func (*FileAsset) Location added in v0.15.0

func (a *FileAsset) Location() url.URL

Location implements RelativePublicationAsset

func (*FileAsset) MediaType

func (a *FileAsset) MediaType(ctx context.Context) mediatype.MediaType

MediaType implements PublicationAsset

func (*FileAsset) Name

func (a *FileAsset) Name() string

Name implements PublicationAsset

type GCSAsset added in v0.9.0

type GCSAsset struct {
	// contains filtered or unexported fields
}

Represents a publication stored on an Amazon S3-compatible remote server.

func GCS added in v0.9.0

func GCS(client *storage.Client, uri url.AbsoluteURL) *GCSAsset

func GCSWithMediaType added in v0.9.0

func GCSWithMediaType(client *storage.Client, uri url.AbsoluteURL, mediatype *mediatype.MediaType) *GCSAsset

Creates a S3Asset from a File and an optional media type, when known.

func (*GCSAsset) CreateFetcher added in v0.9.0

func (a *GCSAsset) CreateFetcher(ctx context.Context, dependencies Dependencies, credentials string) (fetcher.Fetcher, error)

CreateFetcher implements PublicationAsset

func (*GCSAsset) CreateRelativeFetcher added in v0.15.0

func (a *GCSAsset) CreateRelativeFetcher(ctx context.Context, root url.URL) (fetcher.Fetcher, error)

CreateRelativeFetcher implements RelativePublicationAsset

func (*GCSAsset) Location added in v0.15.0

func (a *GCSAsset) Location() url.URL

Location implements RelativePublicationAsset

func (*GCSAsset) MediaType added in v0.9.0

func (a *GCSAsset) MediaType(ctx context.Context) mediatype.MediaType

MediaType implements PublicationAsset

func (*GCSAsset) Name added in v0.9.0

func (a *GCSAsset) Name() string

Name implements PublicationAsset

type HTTPAsset added in v0.9.0

type HTTPAsset struct {
	// contains filtered or unexported fields
}

Represents a publication stored on an Amazon S3-compatible remote server.

func HTTP added in v0.9.0

func HTTP(client *http.Client, url url.AbsoluteURL) *HTTPAsset

func HTTPWithMediaType added in v0.9.0

func HTTPWithMediaType(client *http.Client, url url.AbsoluteURL, mediatype *mediatype.MediaType) *HTTPAsset

Creates a HTTPAsset from a File and an optional media type, when known.

func (*HTTPAsset) CreateFetcher added in v0.9.0

func (a *HTTPAsset) CreateFetcher(ctx context.Context, dependencies Dependencies, credentials string) (fetcher.Fetcher, error)

CreateFetcher implements PublicationAsset

func (*HTTPAsset) CreateRelativeFetcher added in v0.15.0

func (a *HTTPAsset) CreateRelativeFetcher(ctx context.Context, root url.URL) (fetcher.Fetcher, error)

CreateRelativeFetcher implements RelativePublicationAsset

func (*HTTPAsset) Location added in v0.15.0

func (a *HTTPAsset) Location() url.URL

Location implements RelativePublicationAsset

func (*HTTPAsset) MediaType added in v0.9.0

func (a *HTTPAsset) MediaType(ctx context.Context) mediatype.MediaType

MediaType implements PublicationAsset

func (*HTTPAsset) Name added in v0.9.0

func (a *HTTPAsset) Name() string

Name implements PublicationAsset

type PublicationAsset

type PublicationAsset interface {
	Name() string                                                                                              // Name of the asset, e.g. a filename.
	MediaType(ctx context.Context) mediatype.MediaType                                                         // Media type of the asset. If unknown, fallback on `MediaType.Binary`.
	CreateFetcher(ctx context.Context, dependencies Dependencies, credentials string) (fetcher.Fetcher, error) // Creates a fetcher used to access the asset's content.
}

Represents a digital medium (e.g. a file) offering access to a publication.

type RelativePublicationAsset added in v0.15.0

type RelativePublicationAsset interface {
	PublicationAsset

	// The URL of the asset within its medium, e.g. a file path URL, or an
	// HTTP(S), S3 or GS URL. HREFs relative to the asset resolve against it.
	Location() url.URL

	// Creates a fetcher serving the resources surrounding this asset, rooted at [root]:
	// a link with HREF `a/file.xhtml` is fetched from `a/file.xhtml` under the root
	// directory, whether the asset lives on a local file system or on a remote server.
	//
	// [root] must be the URL of a directory containing the asset, typically derived
	// from [Location] by resolving a `./` or `../` reference against it.
	CreateRelativeFetcher(ctx context.Context, root url.URL) (fetcher.Fetcher, error)
}

A PublicationAsset which can also provide access to resources located relative to itself, e.g. the resources referenced by a bare (exploded) Readium Web Publication Manifest.

type S3Asset added in v0.9.0

type S3Asset struct {
	// contains filtered or unexported fields
}

Represents a publication stored on an Amazon S3-compatible remote server.

func S3 added in v0.9.0

func S3(client *s3.Client, uri url.AbsoluteURL) *S3Asset

func S3WithMediaType added in v0.9.0

func S3WithMediaType(client *s3.Client, uri url.AbsoluteURL, mediatype *mediatype.MediaType) *S3Asset

Creates a S3Asset from a File and an optional media type, when known.

func (*S3Asset) CreateFetcher added in v0.9.0

func (a *S3Asset) CreateFetcher(ctx context.Context, dependencies Dependencies, credentials string) (fetcher.Fetcher, error)

CreateFetcher implements PublicationAsset

func (*S3Asset) CreateRelativeFetcher added in v0.15.0

func (a *S3Asset) CreateRelativeFetcher(ctx context.Context, root url.URL) (fetcher.Fetcher, error)

CreateRelativeFetcher implements RelativePublicationAsset

func (*S3Asset) Location added in v0.15.0

func (a *S3Asset) Location() url.URL

Location implements RelativePublicationAsset

func (*S3Asset) MediaType added in v0.9.0

func (a *S3Asset) MediaType(ctx context.Context) mediatype.MediaType

MediaType implements PublicationAsset

func (*S3Asset) Name added in v0.9.0

func (a *S3Asset) Name() string

Name implements PublicationAsset

Jump to

Keyboard shortcuts

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