@inrupt/solid-client-access-grants / resource
Module: resource#
Functions#
createContainerInContainer#
▸ createContainerInContainer(containerUrl
, accessGrant
, options?
): Promise
<Readonly
<{}> & WithResourceInfo
>
Create an empty Container inside the Container at the given URL.
Throws an error if creating the Container failed, e.g. because the current user does not have permissions to. In particular, the Access Grant being used should at least append access to the target Container.
The Container in which to create the new Container should itself already exist.
This function is primarily useful if the current user does not have access to change existing files in a Container, but is allowed to add new files; in other words, they have Append, but not Write access to a Container. This is useful in situations where someone wants to allow others to, for example, send notifications to their Pod, but not to view or delete existing notifications. You can pass a suggestion for the new Resource’s name, but the server may decide to give it another name — for example, if a Resource with that name already exists inside the given Container. If the user does have access to write directly to a given location, createContainerAt will do the job just fine, and does not require the parent Container to exist in advance.
Parameters#
Name |
Type |
Description |
---|---|---|
|
|
URL of the Container in which the empty Container is to be created. |
|
|
The Access Grant that would allow the Agent/Application to perform this operation. |
|
|
Optional parameter: - |
Returns#
Promise
<Readonly
<{}> & WithResourceInfo
>
A promise that resolves to a SolidDataset with ResourceInfo if successful, and that rejects otherwise.
Since
2.1.0
Defined in#
src/resource/createContainerInContainer.ts:62
deleteFile#
▸ deleteFile(fileUrl
, accessGrant
, options?
): Promise
<void
>
Delete a File from a Solid Pod using an Access Grant to prove the caller is authorized to overwrite the target file.
Parameters#
Name |
Type |
Description |
---|---|---|
|
|
The URL of the target file. |
|
|
The Access Grant VC proving the caller is authorized. |
|
Optional properties to customise the request behaviour. |
Returns#
Promise
<void
>
A promise that resolves to a SolidDataset if successful, and that rejects otherwise.
See
@inrupt/solid-client’s deleteSolidDataset
Since
unreleased
Defined in#
src/resource/deleteFile.ts:45
deleteSolidDataset#
▸ deleteSolidDataset(datasetUrl
, accessGrant
, options?
): Promise
<void
>
Delete a Dataset from a Solid Pod using an Access Grant to prove the caller is authorized to overwrite the target dataset.
Parameters#
Name |
Type |
Description |
---|---|---|
|
|
The URL of the target dataset. |
|
|
The Access Grant VC proving the caller is authorized. |
|
Optional properties to customise the request behaviour. |
Returns#
Promise
<void
>
A promise that resolves to a SolidDataset if successful, and that rejects otherwise.
See
@inrupt/solid-client’s deleteSolidDataset
Since
unreleased
Defined in#
src/resource/deleteSolidDataset.ts:45
getFile#
▸ getFile(resourceUrl
, accessGrant
, options?
): Promise
<Blob
& WithResourceInfo
& {}>
Retrieve a File from a Solid Pod using an Access Grant to prove the caller is authorized to access the target resource.
Parameters#
Name |
Type |
Description |
---|---|---|
|
|
The URL of the target resource. |
|
|
The Access Grant VC proving the caller is authorized. |
|
Optional properties to customise the request behaviour. |
Returns#
Promise
<Blob
& WithResourceInfo
& {}>
A promise that resolves to a File if successful, and that rejects otherwise.
See
@inrupt/solid-client’s getFile
Since
0.4.0
Defined in#
src/resource/file.ts:50
getSolidDataset#
▸ getSolidDataset(datasetUrl
, accessGrant
, options?
): Promise
<Readonly
<{}> & WithResourceInfo
& {}>
Retrieve a Dataset from a Solid Pod using an Access Grant to prove the caller is authorized to access the target dataset.
Parameters#
Name |
Type |
Description |
---|---|---|
|
|
The URL of the target dataset. |
|
|
The Access Grant VC proving the caller is authorized. |
|
Optional properties to customise the request behaviour. |
Returns#
Promise
<Readonly
<{}> & WithResourceInfo
& {}>
A promise that resolves to a SolidDataset if successful, and that rejects otherwise.
See
@inrupt/solid-client’s getSolidDataset
Since
0.4.0
Defined in#
src/resource/getSolidDataset.ts:45
overwriteFile#
▸ overwriteFile<T
>(resourceUrl
, file
, accessGrant
, options?
): Promise
<T
& WithResourceInfo
>
Overwrites the file using an Access Grant to prove the caller is authorized to write to the given resource URL.
Note
This function does not support saving a file if the file does not
yet exist, unlike its @inrupt/solid-client
counterpart. To save a new file
in a container, you should use saveFileInContainer
instead.
Type parameters#
Name |
Type |
---|---|
|
extends |
Parameters#
Name |
Type |
Description |
---|---|---|
|
|
The URL where the file is located. |
|
|
The file to be written. |
|
|
The Access Grant VC proving the caller is authorized. |
|
|
Optional properties to customise the request behaviour, or override the Content-Type of the file. |
Returns#
Promise
<T
& WithResourceInfo
>
A promise that resolves to a File if successful, and that rejects otherwise.
See
@inrupt/solid-client’s overwriteFile
Since
1.1.0
Defined in#
src/resource/file.ts:93
saveFileInContainer#
▸ saveFileInContainer<T
>(containerUrl
, file
, accessGrant
, options?
): Promise
<T
& WithResourceInfo
>
Saves a file in the given container URL using an Access Grant to prove the caller is authorized to save a file in the given container.
Type parameters#
Name |
Type |
---|---|
|
extends |
Parameters#
Name |
Type |
Description |
---|---|---|
|
|
The container URL where the file is to be saved. |
|
|
The file to be written. |
|
|
The Access Grant VC proving the caller is authorized. |
|
|
Optional properties to customise the request behaviour, or override the Content-Type of the file. |
Returns#
Promise
<T
& WithResourceInfo
>
A promise that resolves to a File if successful, and that rejects otherwise.
See
@inrupt/solid-client’s saveFileInContainer
Since
1.1.0
Defined in#
src/resource/file.ts:136
saveSolidDatasetAt#
▸ saveSolidDatasetAt<Dataset
>(datasetUrl
, solidDataset
, accessGrant
, options?
): Promise
<Dataset
& WithResourceInfo
& {} & Readonly
<{}> & {}>
Saves a Dataset in a Solid Pod using an Access Grant to prove the caller is authorized to write or append to the dataset at the given dataset URL.
Note
This function does not support saving a dataset if the
dataset does not yet exist, unlike its @inrupt/solid-client
counterpart.
Type parameters#
Name |
Type |
---|---|
|
extends |
Parameters#
Name |
Type |
Description |
---|---|---|
|
|
The URL of the dataset to save. |
|
|
- |
|
|
The Access Grant VC proving the caller is authorized. |
|
Optional properties to customise the request behaviour. |
Returns#
Promise
<Dataset
& WithResourceInfo
& {} & Readonly
<{}> & {}>
A promise that resolves to a SolidDataset if successful, and that rejects otherwise.
See
@inrupt/solid-client’s saveSolidDatasetAt
Since
0.4.0
Defined in#
src/resource/saveSolidDatasetAt.ts:50
saveSolidDatasetInContainer#
▸ saveSolidDatasetInContainer(containerUrl
, solidDataset
, accessGrant
, options
): Promise
<Readonly
<{}> & WithResourceInfo
>
Given a SolidDataset, store it in a Solid Pod as a new Resource inside a Container.
The Container at the given URL should already exist; if it does not, you can initialise it first using createContainerAt, or directly save the SolidDataset at the desired location using resource.saveSolidDatasetAt.
This function is primarily useful if the current user has not been granted access to change existing files in a Container, but is allowed to add new files; in other words, they have been granted Append, but not Write access to a Container. This is useful in situations where someone wants to allow others to, for example, send notifications to their Pod, but not to view or delete existing notifications. You can pass a suggestion for the new Resource’s name, but the server may decide to give it another name — for example, if a Resource with that name already exists inside the given Container. If the user does have access to write directly to a given location, resource.saveSolidDatasetAt will do the job just fine, and does not require the parent Container to exist in advance.
Parameters#
Name |
Type |
Description |
---|---|---|
|
|
URL of the Container in which to create a new Resource. |
|
|
The SolidDataset to save to a new Resource in the given Container. |
|
|
The Access Grant that would allow the Agent/Application to perform this operation. |
|
|
Optional parameter |
Returns#
Promise
<Readonly
<{}> & WithResourceInfo
>
A Promise resolving to a SolidDataset containing the saved data. The Promise rejects if the save failed.
See
@inrupt/solid-client’s saveSolidDatasetInContainer
Since
2.1.0
Defined in#
src/resource/saveSolidDatasetInContainer.ts:63