blob

Types from PocketBase's Go package blob, as JavaScript sees them: you get these objects from $app and the other globals and from hook events, and call their methods by their JS names (Go's FindRecordById is findRecordById). The same package in Go: blob.

blob.ListObject

ListObject represents a single blob returned from List.

Member Type
key string Key is the key for this blob.
modTime time.Time ModTime is the time the blob was last modified.
size number Size is the size of the blob's content in bytes.
md5 string|Array<number> MD5 is an MD5 hash of the blob contents or nil if not available.
isDir boolean IsDir indicates that this result represents a "directory" in the hierarchical namespace, ending in ListOptions.Delimiter. Key can be passed as ListOptions.Prefix to list items in the "directory". Fields other than Key and IsDir will not be set if IsDir is true.

blob.Attributes

Attributes contains attributes about a blob.

Member Type
cacheControl string CacheControl specifies caching attributes that services may use when serving the blob. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
contentDisposition string ContentDisposition specifies whether the blob content is expected to be displayed inline or as an attachment. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
contentEncoding string ContentEncoding specifies the encoding used for the blob's content, if any. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
contentLanguage string ContentLanguage specifies the language used in the blob's content, if any. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Language
contentType string ContentType is the MIME type of the blob. It will not be empty. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type
metadata { [key: string]: any } Metadata holds key/value pairs associated with the blob. Keys are guaranteed to be in lowercase, even if the backend service has case-sensitive keys (although note that Metadata written via this package will always be lowercased). If there are duplicate case-insensitive keys (e.g., "foo" and "FOO"), only one value will be kept, and it is undefined which one.
createTime time.Time CreateTime is the time the blob was created, if available. If not available, CreateTime will be the zero time.
modTime time.Time ModTime is the time the blob was last modified.
size number Size is the size of the blob's content in bytes.
md5 string|Array<number> MD5 is an MD5 hash of the blob contents or nil if not available.
eTag string ETag for the blob; see https://en.wikipedia.org/wiki/HTTP_ETag.

blob.WriterOptions

WriterOptions sets options for NewWriter.

Member Type
bufferSize number BufferSize changes the default size in bytes of the chunks that Writer will upload in a single request; larger blobs will be split into multiple requests.
maxConcurrency number MaxConcurrency changes the default concurrency for parts of an upload.
cacheControl string CacheControl specifies caching attributes that services may use when serving the blob. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
contentDisposition string ContentDisposition specifies whether the blob content is expected to be displayed inline or as an attachment. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
contentEncoding string ContentEncoding specifies the encoding used for the blob's content, if any. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
contentLanguage string ContentLanguage specifies the language used in the blob's content, if any. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Language
contentType string ContentType specifies the MIME type of the blob being written. If not set, it will be inferred from the content using the algorithm described at http://mimesniff.spec.whatwg.org/. Set DisableContentTypeDetection to true to disable the above and force the ContentType to stay empty. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type
disableContentTypeDetection boolean When true, if ContentType is the empty string, it will stay the empty string rather than being inferred from the content. Note that while the blob will be written with an empty string ContentType, most providers will fill one in during reads, so don't expect an empty ContentType if you read the blob back.
contentMD5 string|Array<number> ContentMD5 is used as a message integrity check. If len(ContentMD5) > 0, the MD5 hash of the bytes written must match ContentMD5, or Close will return an error without completing the write. https://tools.ietf.org/html/rfc1864
metadata { [key: string]: any } Metadata holds key/value strings to be associated with the blob, or nil. Keys may not be empty, and are lowercased before being written. Duplicate case-insensitive keys (e.g., "foo" and "FOO") will result in an error.

blob.Driver

Driver provides read, write and delete operations on objects within it on the blob service.

Member Type
normalizeError() (err: Error): void
attributes() (ctx: context.Context, key: string): (Attributes) Attributes returns attributes for the blob. If the specified object does not exist, Attributes must return an ErrNotFound. The portable type will not modify the returned Attributes.
listPaged() (ctx: context.Context, opts: ListOptions): (ListPage) ListPaged lists objects in the bucket, in lexicographical order by UTF-8-encoded key, returning pages of objects at a time. Services are only required to be eventually consistent with respect to recently written or deleted objects. That is to say, there is no guarantee that an object that's been written will immediately be returned from ListPaged.
newRangeReader() (ctx: context.Context, key: string, offset: number, length: number): DriverReader NewRangeReader returns a Reader that reads part of an object, reading at most length bytes starting at the given offset. If length is negative, it will read until the end of the object. If the specified object does not exist, NewRangeReader must return an ErrNotFound.
newTypedWriter() (ctx: context.Context, key: string, contentType: string, opts: WriterOptions): DriverWriter NewTypedWriter returns Writer that writes to an object associated with key.
copy() (ctx: context.Context, dstKey: string, srcKey: string): void Copy copies the object associated with srcKey to dstKey.
delete() (ctx: context.Context, key: string): void Delete deletes the object associated with key. If the specified object does not exist, Delete must return an ErrNotFound.
close() (): void Close cleans up any resources used by the Bucket. Once Close is called, there will be no method calls to the Bucket other than As, ErrorAs, and ErrorCode. There may be open readers or writers that will receive calls. It is up to the driver as to how these will be handled.

blob.Reader

Reader reads bytes from a blob. It implements io.ReadSeekCloser, and must be closed after reads are finished.

Member Type
read() (p: string|Array<number>): number Read implements io.Reader (https://golang.org/pkg/io/#Reader).
seek() (offset: number, whence: number): number Seek implements io.Seeker (https://golang.org/pkg/io/#Seeker).
close() (): void Close implements io.Closer (https://golang.org/pkg/io/#Closer).
contentType() (): string ContentType returns the MIME type of the blob.
modTime() (): time.Time ModTime returns the time the blob was last modified.
size() (): number Size returns the size of the blob content in bytes.
writeTo() (w: io.Writer): number WriteTo reads from r and writes to w until there's no more data or an error occurs. The return value is the number of bytes written to w.

blob.Writer

Writer writes bytes to a blob.

It implements io.WriteCloser (https://golang.org/pkg/io/#Closer), and must be closed after all writes are done.

Member Type
write() (p: string|Array<number>): number Write implements the io.Writer interface (https://golang.org/pkg/io/#Writer).
close() (): void Close closes the blob writer. The write operation is not guaranteed to have succeeded until Close returns with no error.
readFrom() (r: io.Reader): number ReadFrom reads from r and writes to w until EOF or error. The return value is the number of bytes read from r.

blob.ListOptions

ListOptions sets options for listing blobs via Bucket.List.

Member Type
prefix string Prefix indicates that only blobs with a key starting with this prefix should be returned.
delimiter string Delimiter sets the delimiter used to define a hierarchical namespace, like a filesystem with "directories". It is highly recommended that you use "" or "/" as the Delimiter. Other values should work through this API, but service UIs generally assume "/".
pageSize number PageSize sets the maximum number of objects to be returned. 0 means no maximum; driver implementations should choose a reasonable max. It is guaranteed to be >= 0.
pageToken string|Array<number> PageToken may be filled in with the NextPageToken from a previous ListPaged call.

blob.ListPage

ListPage represents a page of results return from ListPaged.

Member Type
objects Array<(ListObject | undefined)> Objects is the slice of objects found. If ListOptions.PageSize > 0, it should have at most ListOptions.PageSize entries.
nextPageToken string|Array<number> NextPageToken should be left empty unless there are more objects to return. The value may be returned as ListOptions.PageToken on a subsequent ListPaged call, to fetch the next page of results. It can be an arbitrary []byte; it need not be a valid key.

blob.DriverReader

DriverReader reads an object from the blob.

Member Type
attributes() (): (ReaderAttributes) Attributes returns a subset of attributes about the blob. The portable type will not modify the returned ReaderAttributes.

blob.DriverWriter

DriverWriter writes an object to the blob.

blob.ReaderAttributes

ReaderAttributes contains a subset of attributes about a blob that are accessible from Reader.

Member Type
contentType string ContentType is the MIME type of the blob object. It must not be empty. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type
modTime time.Time ModTime is the time the blob object was last modified.
size number Size is the size of the object in bytes.