Class: Leaf
Represents the current status of a specific Leaf on a Pod as known by LDO.
Example
Hierarchy
↳ Leaf
Constructors
constructor
• new Leaf(uri
, context
): Leaf
Parameters
Name | Type | Description |
---|---|---|
uri |
LeafUri |
The uri of the leaf |
context |
SolidLdoDatasetContext |
SolidLdoDatasetContext for the parent dataset |
Returns
Overrides
Defined in
packages/solid/src/resource/Leaf.ts:78
Properties
absent
• Protected
absent: undefined
| boolean
True if this resource has been fetched but does not exist
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:84
binaryData
• Protected
binaryData: undefined
| { blob
: Blob
; mimeType
: string
}
The raw binary data if this leaf is a Binary resource
Defined in
packages/solid/src/resource/Leaf.ts:72
context
• Protected
Readonly
context: SolidLdoDatasetContext
The SolidLdoDatasetContext from the Parent Dataset
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:51
didInitialFetch
• Protected
didInitialFetch: boolean
= false
True if this resource has been fetched at least once
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:78
isError
• Readonly
isError: false
Indicates that this resource is not an error
Defined in
packages/solid/src/resource/Leaf.ts:56
requester
• Protected
requester: LeafBatchedRequester
Batched Requester for the Leaf
Overrides
Defined in
packages/solid/src/resource/Leaf.ts:46
status
• status: UnexpectedResourceError
| NoncompliantPodError
| ServerHttpError
| UnexpectedHttpError
| UnauthenticatedHttpError
| UnauthorizedHttpError
| CreateSuccess
| BinaryReadSuccess
| DataReadSuccess
| AbsentReadSuccess
| DeleteSuccess
| UpdateSuccess
| Unfetched
The status of the last request made for this leaf
Overrides
Defined in
packages/solid/src/resource/Leaf.ts:61
type
• Readonly
type: "leaf"
Indicates that this resource is a leaf resource
Overrides
Defined in
packages/solid/src/resource/Leaf.ts:51
uri
• Readonly
uri: LeafUri
The URI of the leaf
Overrides
Defined in
packages/solid/src/resource/Leaf.ts:40
wacRule
• Protected
Optional
wacRule: WacRule
If a wac rule was fetched, it is cached here
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:96
wacUri
• Protected
Optional
wacUri: LeafUri
If a wac uri is fetched, it is cached here
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:90
Methods
addListener
▸ addListener\<E
>(event
, listener
): this
Type parameters
Name | Type |
---|---|
E |
extends "update" |
Parameters
Name | Type |
---|---|
event |
E |
listener |
{ update : () => void }[E ] |
Returns
this
Inherited from
Defined in
node_modules/typed-emitter/index.d.ts:22
createAndOverwrite
▸ createAndOverwrite(): Promise
\<ResourceResult
\<LeafCreateAndOverwriteResult
, Leaf
>>
Creates a leaf at this URI and overwrites any that already exists
Returns
Promise
\<ResourceResult
\<LeafCreateAndOverwriteResult
, Leaf
>>
LeafCreateAndOverwriteResult
Example
Overrides
Defined in
packages/solid/src/resource/Leaf.ts:402
createIfAbsent
▸ createIfAbsent(): Promise
\<ResourceResult
\<LeafCreateIfAbsentResult
, Leaf
>>
Creates a leaf at this URI if the leaf doesn't already exist
Returns
Promise
\<ResourceResult
\<LeafCreateIfAbsentResult
, Leaf
>>
LeafCreateIfAbsentResult
Example
Overrides
Defined in
packages/solid/src/resource/Leaf.ts:423
delete
▸ delete(): Promise
\<DeleteResult
>
Deletes this leaf and all its contents
Returns
Promise
\<DeleteResult
>
A Delete result for this leaf
Defined in
packages/solid/src/resource/Leaf.ts:372
emit
▸ emit\<E
>(event
, ...args
): boolean
Type parameters
Name | Type |
---|---|
E |
extends "update" |
Parameters
Name | Type |
---|---|
event |
E |
...args |
Parameters \<{ update : () => void }[E ]> |
Returns
boolean
Inherited from
Defined in
node_modules/typed-emitter/index.d.ts:32
emitThisAndParent
▸ emitThisAndParent(): void
Emits an update event for both this resource and the parent
Returns
void
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:313
eventNames
▸ eventNames(): (string
| symbol
)[]
Returns
(string
| symbol
)[]
Inherited from
Defined in
node_modules/typed-emitter/index.d.ts:34
getBlob
▸ getBlob(): undefined
| Blob
If this resource is a binary resource, returns the Blob
Returns
undefined
| Blob
The Blob if this resource is a binary resource, undefined otherwise
Example
Defined in
packages/solid/src/resource/Leaf.ts:153
getMaxListeners
▸ getMaxListeners(): number
Returns
number
Inherited from
Defined in
node_modules/typed-emitter/index.d.ts:39
getMimeType
▸ getMimeType(): undefined
| string
If this resource is a binary resource, returns the mime type
Returns
undefined
| string
The mime type if this resource is a binary resource, undefined otherwise
Example
Defined in
packages/solid/src/resource/Leaf.ts:138
getParentContainer
▸ getParentContainer(): Promise
\<Container
>
Gets the parent container for this leaf by making a request
Returns
Promise
\<Container
>
The parent container
Example
const leaf = solidLdoDataset
.getResource("https://example.com/container/resource.ttl");
const leafParent = await leaf.getParentContainer();
if (!leafParent.isError) {
// Logs "https://example.com/container/"
console.log(leafParent.uri);
}
Overrides
Defined in
packages/solid/src/resource/Leaf.ts:319
getRootContainer
▸ getRootContainer(): Promise
\<CheckRootResultError
| Container
>
Gets the root container for this leaf.
Returns
Promise
\<CheckRootResultError
| Container
>
The root container for this leaf
Example
Suppose the root container is at https://example.com/
const leaf = ldoSolidDataset
.getResource("https://example.com/container/resource.ttl");
const rootContainer = await leaf.getRootContainer();
if (!rootContainer.isError) {
// logs "https://example.com/"
console.log(rootContainer.uri);
}
Overrides
Defined in
packages/solid/src/resource/Leaf.ts:341
getWac
▸ getWac(options?
): Promise
\<UnexpectedResourceError
| NoncompliantPodError
| ServerHttpError
| UnexpectedHttpError
| UnauthenticatedHttpError
| UnauthorizedHttpError
| NotFoundHttpError
| GetWacRuleSuccess
| WacRuleAbsent
>
Retrieves web access control (WAC) rules for this resource
Parameters
Name | Type | Description |
---|---|---|
options? |
Object |
set the "ignoreCache" field to true to ignore any cached information on WAC rules. |
options.ignoreCache |
boolean |
- |
Returns
Promise
\<UnexpectedResourceError
| NoncompliantPodError
| ServerHttpError
| UnexpectedHttpError
| UnauthenticatedHttpError
| UnauthorizedHttpError
| NotFoundHttpError
| GetWacRuleSuccess
| WacRuleAbsent
>
WAC Rules results
Example
const resource = ldoSolidDataset
.getResource("https://example.com/container/resource.ttl");
const wacRulesResult = await resource.getWac();
if (!wacRulesResult.isError) {
const wacRules = wacRulesResult.wacRule;
// True if the resource is publicly readable
console.log(wacRules.public.read);
// True if authenticated agents can write to the resource
console.log(wacRules.authenticated.write);
// True if the given WebId has append access
console.log(
wacRules.agent[https://example.com/person1/profile/card#me].append
);
// True if the given WebId has control access
console.log(
wacRules.agent[https://example.com/person1/profile/card#me].control
);
}
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:596
getWacUri
▸ getWacUri(options?
): Promise
\<GetWacUriResult
>
Retrieves the URI for the web access control (WAC) rules for this resource
Parameters
Name | Type | Description |
---|---|---|
options? |
Object |
set the "ignoreCache" field to true to ignore any cached information on WAC rules. |
options.ignoreCache |
boolean |
- |
Returns
Promise
\<GetWacUriResult
>
WAC Rules results
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:545
handleCreateAndOverwrite
▸ handleCreateAndOverwrite(): Promise
\<UnexpectedResourceError
| ServerHttpError
| UnexpectedHttpError
| UnauthenticatedHttpError
| UnauthorizedHttpError
| CreateSuccess
>
Helper method that handles the core functions for creating and overwriting a resource
Returns
Promise
\<UnexpectedResourceError
| ServerHttpError
| UnexpectedHttpError
| UnauthenticatedHttpError
| UnauthorizedHttpError
| CreateSuccess
>
DeleteResult
Inherited from
Resource.handleCreateAndOverwrite
Defined in
packages/solid/src/resource/Resource.ts:457
handleCreateIfAbsent
▸ handleCreateIfAbsent(): Promise
\<UnexpectedResourceError
| NoncompliantPodError
| ServerHttpError
| UnexpectedHttpError
| UnauthenticatedHttpError
| UnauthorizedHttpError
| CreateSuccess
| BinaryReadSuccess
| DataReadSuccess
| ContainerReadSuccess
>
Helper method that handles the core functions for creating a resource if absent
Returns
Promise
\<UnexpectedResourceError
| NoncompliantPodError
| ServerHttpError
| UnexpectedHttpError
| UnauthenticatedHttpError
| UnauthorizedHttpError
| CreateSuccess
| BinaryReadSuccess
| DataReadSuccess
| ContainerReadSuccess
>
DeleteResult
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:493
handleDelete
▸ handleDelete(): Promise
\<DeleteResult
>
Helper method that handles the core functions for deleting a resource
Returns
Promise
\<DeleteResult
>
DeleteResult
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:405
handleRead
▸ handleRead(): Promise
\<UnexpectedResourceError
| NoncompliantPodError
| ServerHttpError
| UnexpectedHttpError
| UnauthenticatedHttpError
| UnauthorizedHttpError
| BinaryReadSuccess
| DataReadSuccess
| ContainerReadSuccess
| AbsentReadSuccess
>
A helper method that handles the core functions for reading
Returns
Promise
\<UnexpectedResourceError
| NoncompliantPodError
| ServerHttpError
| UnexpectedHttpError
| UnauthenticatedHttpError
| UnauthorizedHttpError
| BinaryReadSuccess
| DataReadSuccess
| ContainerReadSuccess
| AbsentReadSuccess
>
ReadResult
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:343
isAbsent
▸ isAbsent(): undefined
| boolean
Is this resource currently absent (it does not exist)
Returns
undefined
| boolean
true if the resource is absent, false if not, undefined if unknown
Example
// Logs "undefined"
console.log(resource.isAbsent());
const result = resource.read();
if (!result.isError) {
// False if the resource exists, true if it does not
console.log(resource.isAbsent());
}
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:280
isBinary
▸ isBinary(): undefined
| boolean
Check if this resource is a binary resource
Returns
undefined
| boolean
True if this resource is a binary resource, false if not, undefined if unknown
Example
// Logs "undefined"
console.log(leaf.isBinary());
const result = await leaf.read();
if (!result.isError) {
// Logs "true"
console.log(leaf.isBinary());
}
Defined in
packages/solid/src/resource/Leaf.ts:173
isCreating
▸ isCreating(): boolean
Checks to see if this resource is being created
Returns
boolean
true if the resource is currently being created
Example
resource.read().then(() => {
// Logs "false"
console.log(resource.isCreating())
});
// Logs "true"
console.log(resource.isCreating());
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:144
isDataResource
▸ isDataResource(): undefined
| boolean
Check if this resource is a data (RDF) resource
Returns
undefined
| boolean
True if this resource is a data resource, false if not, undefined if unknown
Example
// Logs "undefined"
console.log(leaf.isDataResource());
const result = await leaf.read();
if (!result.isError) {
// Logs "true"
console.log(leaf.isDataResource());
}
Defined in
packages/solid/src/resource/Leaf.ts:196
isDeleting
▸ isDeleting(): boolean
Checks to see if this resource is being deleted
Returns
boolean
true if the resource is currently being deleted
Example
resource.read().then(() => {
// Logs "false"
console.log(resource.isDeleting())
});
// Logs "true"
console.log(resource.isDeleting());
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:180
isDoingInitialFetch
▸ isDoingInitialFetch(): boolean
Checks to see if this resource is being read for the first time
Returns
boolean
true if the resource is currently being read for the first time
Example
resource.read().then(() => {
// Logs "false"
console.log(resource.isDoingInitialFetch())
});
// Logs "true"
console.log(resource.isDoingInitialFetch());
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:198
isFetched
▸ isFetched(): boolean
Check to see if this resource has been fetched
Returns
boolean
true if this resource has been fetched before
Example
// Logs "false"
console.log(resource.isFetched());
const result = await resource.read();
if (!result.isError) {
// Logs "true"
console.log(resource.isFetched());
}
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:242
isLoading
▸ isLoading(): boolean
Checks to see if this resource is loading in any way
Returns
boolean
true if the resource is currently loading
Example
resource.read().then(() => {
// Logs "false"
console.log(resource.isLoading())
});
// Logs "true"
console.log(resource.isLoading());
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:126
isPresent
▸ isPresent(): undefined
| boolean
Is this resource currently present on the Pod
Returns
undefined
| boolean
false if the resource is absent, true if not, undefined if unknown
Example
// Logs "undefined"
console.log(resource.isPresent());
const result = resource.read();
if (!result.isError) {
// True if the resource exists, false if it does not
console.log(resource.isPresent());
}
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:299
isReading
▸ isReading(): boolean
Checks to see if this resource is being read
Returns
boolean
true if the resource is currently being read
Example
resource.read().then(() => {
// Logs "false"
console.log(resource.isReading())
});
// Logs "true"
console.log(resource.isReading());
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:162
isReloading
▸ isReloading(): boolean
Checks to see if this resource is being read for a subsequent time
Returns
boolean
true if the resource is currently being read for a subsequent time
Example
await resource.read();
resource.read().then(() => {
// Logs "false"
console.log(resource.isCreating())
});
// Logs "true"
console.log(resource.isCreating());
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:217
isUnfetched
▸ isUnfetched(): boolean
Check to see if this resource is currently unfetched
Returns
boolean
true if the resource is currently unfetched
Example
// Logs "true"
console.log(resource.isUnetched());
const result = await resource.read();
if (!result.isError) {
// Logs "false"
console.log(resource.isUnfetched());
}
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:261
isUpdating
▸ isUpdating(): boolean
Checks to see if the resource is currently updating data
Returns
boolean
true if the current resource is updating
Example
leaf.update(datasetChanges).then(() => {
// Logs "false"
console.log(leaf.isUpdating())
});
// Logs "true"
console.log(leaf.isUpdating());
Defined in
packages/solid/src/resource/Leaf.ts:123
isUploading
▸ isUploading(): boolean
Checks to see if the resource is currently uploading data
Returns
boolean
true if the current resource is uploading
Example
leaf.uploadAndOverwrite(new Blob("some text"), "text/txt").then(() => {
// Logs "false"
console.log(leaf.isUploading())
});
// Logs "true"
console.log(leaf.isUploading());
Defined in
packages/solid/src/resource/Leaf.ts:105
listenerCount
▸ listenerCount\<E
>(event
): number
Type parameters
Name | Type |
---|---|
E |
extends "update" |
Parameters
Name | Type |
---|---|
event |
E |
Returns
number
Inherited from
Defined in
node_modules/typed-emitter/index.d.ts:37
listeners
▸ listeners\<E
>(event
): { update
: () => void
}[E
][]
Type parameters
Name | Type |
---|---|
E |
extends "update" |
Parameters
Name | Type |
---|---|
event |
E |
Returns
{ update
: () => void
}[E
][]
Inherited from
Defined in
node_modules/typed-emitter/index.d.ts:36
off
▸ off\<E
>(event
, listener
): this
Type parameters
Name | Type |
---|---|
E |
extends "update" |
Parameters
Name | Type |
---|---|
event |
E |
listener |
{ update : () => void }[E ] |
Returns
this
Inherited from
Defined in
node_modules/typed-emitter/index.d.ts:28
on
▸ on\<E
>(event
, listener
): this
Type parameters
Name | Type |
---|---|
E |
extends "update" |
Parameters
Name | Type |
---|---|
event |
E |
listener |
{ update : () => void }[E ] |
Returns
this
Inherited from
Defined in
node_modules/typed-emitter/index.d.ts:23
once
▸ once\<E
>(event
, listener
): this
Type parameters
Name | Type |
---|---|
E |
extends "update" |
Parameters
Name | Type |
---|---|
event |
E |
listener |
{ update : () => void }[E ] |
Returns
this
Inherited from
Defined in
node_modules/typed-emitter/index.d.ts:24
prependListener
▸ prependListener\<E
>(event
, listener
): this
Type parameters
Name | Type |
---|---|
E |
extends "update" |
Parameters
Name | Type |
---|---|
event |
E |
listener |
{ update : () => void }[E ] |
Returns
this
Inherited from
Defined in
node_modules/typed-emitter/index.d.ts:25
prependOnceListener
▸ prependOnceListener\<E
>(event
, listener
): this
Type parameters
Name | Type |
---|---|
E |
extends "update" |
Parameters
Name | Type |
---|---|
event |
E |
listener |
{ update : () => void }[E ] |
Returns
this
Inherited from
Defined in
node_modules/typed-emitter/index.d.ts:26
rawListeners
▸ rawListeners\<E
>(event
): { update
: () => void
}[E
][]
Type parameters
Name | Type |
---|---|
E |
extends "update" |
Parameters
Name | Type |
---|---|
event |
E |
Returns
{ update
: () => void
}[E
][]
Inherited from
Defined in
node_modules/typed-emitter/index.d.ts:35
read
▸ read(): Promise
\<ResourceResult
\<ReadLeafResult
, Leaf
>>
Reads the leaf by making a request
Returns
Promise
\<ResourceResult
\<ReadLeafResult
, Leaf
>>
A read result
Example
Overrides
Defined in
packages/solid/src/resource/Leaf.ts:237
readIfUnfetched
▸ readIfUnfetched(): Promise
\<ResourceResult
\<ReadLeafResult
, Leaf
>>
Makes a request to read this leaf if it hasn't been fetched yet. If it has, return the cached informtation
Returns
Promise
\<ResourceResult
\<ReadLeafResult
, Leaf
>>
a ReadLeafResult
Example
const result = await leaf.read();
if (!result.isError) {
// Will execute without making a request
const result2 = await leaf.readIfUnfetched();
}
Overrides
Defined in
packages/solid/src/resource/Leaf.ts:292
removeAllListeners
▸ removeAllListeners\<E
>(event?
): this
Type parameters
Name | Type |
---|---|
E |
extends "update" |
Parameters
Name | Type |
---|---|
event? |
E |
Returns
this
Inherited from
Defined in
node_modules/typed-emitter/index.d.ts:29
removeListener
▸ removeListener\<E
>(event
, listener
): this
Type parameters
Name | Type |
---|---|
E |
extends "update" |
Parameters
Name | Type |
---|---|
event |
E |
listener |
{ update : () => void }[E ] |
Returns
this
Inherited from
Defined in
node_modules/typed-emitter/index.d.ts:30
setMaxListeners
▸ setMaxListeners(maxListeners
): this
Parameters
Name | Type |
---|---|
maxListeners |
number |
Returns
this
Inherited from
Defined in
node_modules/typed-emitter/index.d.ts:40
setWac
▸ setWac(wacRule
): Promise
\<UnexpectedResourceError
| NoncompliantPodError
| ServerHttpError
| UnexpectedHttpError
| UnauthenticatedHttpError
| UnauthorizedHttpError
| NotFoundHttpError
| SetWacRuleSuccess
>
Sets access rules for a specific resource
Parameters
Name | Type | Description |
---|---|---|
wacRule |
WacRule |
the access rules to set |
Returns
Promise
\<UnexpectedResourceError
| NoncompliantPodError
| ServerHttpError
| UnexpectedHttpError
| UnauthenticatedHttpError
| UnauthorizedHttpError
| NotFoundHttpError
| SetWacRuleSuccess
>
SetWacRuleResult
Example
const resource = ldoSolidDataset
.getResource("https://example.com/container/resource.ttl");
const wacRulesResult = await resource.setWac({
public: {
read: true,
write: false,
append: false,
control: false
},
authenticated: {
read: true,
write: false,
append: true,
control: false
},
agent: {
"https://example.com/person1/profile/card#me": {
read: true,
write: true,
append: true,
control: true
}
}
});
Inherited from
Defined in
packages/solid/src/resource/Resource.ts:669
toReadResult
▸ toReadResult(): ResourceResult
\<ReadLeafResult
, Leaf
>
Converts the current state of this leaf to a readResult
Returns
ResourceResult
\<ReadLeafResult
, Leaf
>
a ReadLeafResult
Overrides
Defined in
packages/solid/src/resource/Leaf.ts:248
update
▸ update(changes
): Promise
\<ResourceResult
\<UpdateResult
, Leaf
>>
Updates a data resource with the changes provided
Parameters
Name | Type | Description |
---|---|---|
changes |
DatasetChanges \<Quad > |
Dataset changes that will be applied to the resoruce |
Returns
Promise
\<ResourceResult
\<UpdateResult
, Leaf
>>
An UpdateResult
Example
import {
updateDataResource,
transactionChanges,
changeData,
createSolidLdoDataset,
} from "@ldo/solid";
//...
// Get a Linked Data Object
const profile = solidLdoDataset
.usingType(ProfileShapeType)
.fromSubject("https://example.com/profile#me");
cosnt resource = solidLdoDataset
.getResource("https://example.com/profile");
// Create a transaction to change data
const cProfile = changeData(profile, resource);
cProfile.name = "John Doe";
// Get data in "DatasetChanges" form
const datasetChanges = transactionChanges(someLinkedDataObject);
// Use "update" to apply the changes
cosnt result = resource.update(datasetChanges);
Defined in
packages/solid/src/resource/Leaf.ts:539
updateWithCreateSuccess
▸ updateWithCreateSuccess(_result
): void
A helper method updates this leaf's internal state upon create success
Parameters
Name | Type | Description |
---|---|---|
_result |
ResourceSuccess |
the result of the create success |
Returns
void
Overrides
Resource.updateWithCreateSuccess
Defined in
packages/solid/src/resource/Leaf.ts:386
updateWithDeleteSuccess
▸ updateWithDeleteSuccess(_result
): void
A helper method updates this leaf's internal state upon delete success
Parameters
Name | Type |
---|---|
_result |
DeleteSuccess |
Returns
void
Overrides
Resource.updateWithDeleteSuccess
Defined in
packages/solid/src/resource/Leaf.ts:357
updateWithReadSuccess
▸ updateWithReadSuccess(result
): void
A helper method updates this leaf's internal state upon read success
Parameters
Name | Type | Description |
---|---|---|
result |
BinaryReadSuccess | DataReadSuccess | AbsentReadSuccess |
the result of the read success |
Returns
void
Overrides
Resource.updateWithReadSuccess
Defined in
packages/solid/src/resource/Leaf.ts:214
uploadAndOverwrite
▸ uploadAndOverwrite(blob
, mimeType
): Promise
\<ResourceResult
\<LeafCreateAndOverwriteResult
, Leaf
>>
Uploads a binary resource to this URI. If there is already a resource present at this URI, it will be overwritten
Parameters
Name | Type | Description |
---|---|---|
blob |
Blob |
the Blob of the binary |
mimeType |
string |
the MimeType of the binary |
Returns
Promise
\<ResourceResult
\<LeafCreateAndOverwriteResult
, Leaf
>>
A LeafCreateAndOverwriteResult
Example
const result = await leaf.uploadAndOverwrite(
new Blob("some text."),
"text/txt",
);
if (!result.isError) {
// Do something
}
Defined in
packages/solid/src/resource/Leaf.ts:457
uploadIfAbsent
▸ uploadIfAbsent(blob
, mimeType
): Promise
\<ResourceResult
\<LeafCreateIfAbsentResult
, Leaf
>>
Uploads a binary resource to this URI tf there not is already a resource present at this URI.
Parameters
Name | Type | Description |
---|---|---|
blob |
Blob |
the Blob of the binary |
mimeType |
string |
the MimeType of the binary |
Returns
Promise
\<ResourceResult
\<LeafCreateIfAbsentResult
, Leaf
>>
A LeafCreateIfAbsentResult
Example
const result = await leaf.uploadIfAbsent(
new Blob("some text."),
"text/txt",
);
if (!result.isError) {
// Do something
}