Skip to content

Function: uploadResource

uploadResource(uri, blob, mimeType, overwrite, options?): Promise\<LeafCreateAndOverwriteResult>

Uploads a binary resource at the provided URI

Parameters

Name Type Description
uri LeafUri The URI of the resource
blob Blob -
mimeType string -
overwrite true If true, the request will overwrite any previous resource at this URI.
options? DatasetRequestOptions Options to provide a fetch function and a local dataset to update.

Returns

Promise\<LeafCreateAndOverwriteResult>

One of many create results depending on the input

Example

Any local RDFJS dataset passed to the options field will be updated with any new RDF data from the create process.

import { createDataResource } from "@ldo/solid";
import { createDataset } from "@ldo/dataset"
import { fetch } from "@inrupt/solid-client-autn-js";

const localDataset = createDataset();
const result = await uploadResource(
  "https://example.com/container/someResource.txt",
  new Blob("some text."),
  "text/txt",
  true,
  { fetch, dataset: localDataset },
);
if (!result.isError) {
  // Do something
}

Defined in

packages/solid/src/requester/requests/uploadResource.ts:50

uploadResource(uri, blob, mimeType, overwrite?, options?): Promise\<LeafCreateIfAbsentResult>

Parameters

Name Type
uri LeafUri
blob Blob
mimeType string
overwrite? false
options? DatasetRequestOptions

Returns

Promise\<LeafCreateIfAbsentResult>

Defined in

packages/solid/src/requester/requests/uploadResource.ts:57

uploadResource(uri, blob, mimeType, overwrite?, options?): Promise\<LeafCreateIfAbsentResult | LeafCreateAndOverwriteResult>

Parameters

Name Type
uri LeafUri
blob Blob
mimeType string
overwrite? boolean
options? DatasetRequestOptions

Returns

Promise\<LeafCreateIfAbsentResult | LeafCreateAndOverwriteResult>

Defined in

packages/solid/src/requester/requests/uploadResource.ts:64