@inrupt/solid-client
    Preparing search index...

    Function saveFileInContainer

    • Saves a file in an existing folder/Container associated with the given URL.

      For example:

      const savedFile = await saveFileInContainer(
      "https://pod.example.com/some/existing/container/",
      new File(["This is a plain piece of text"], "suggestedFileName.txt", { type: "text/plain" }),
      { fetch: fetch }
      );

      For additional example, see Read/Write Files.

      In the options parameter,

      • You can suggest a file name in the slug field. However, the Solid Server may or may not use the suggested slug as the file name.

      • Recommended: You can specify the media type of the file in the contentType. If unspecified, the function uses the default type of application/octet-stream, indicating a binary data file.

      The function saves a file into an existing Container. If the Container does not exist, either:

      • Create the Container first using [[createContainerAt]], and then use the function, or
      • Use [[overwriteFile]] to save the file. [[overwriteFile]] creates the Containers in the saved file path as needed.

      Users who only have Append but not Write access to a Container can use [[saveFileInContainer]] to save new files to the Container. That is, [[saveFileInContainer]] is useful in situations where users can add new files to a Container but not change existing files in the Container, such as users given access to send notifications to another's Pod but not to view or delete existing notifications in that Pod.

      Users with Write access to the given folder/Container may prefer to use [[overwriteFile]].

      Type Parameters

      • FileExt extends File | Blob | File

      Parameters

      • folderUrl: string | Url

        The URL of an existing folder where the new file is saved.

      • file: FileExt

        The file to be written.

      • Optionaloptions: Partial<SaveFileOptions>

        Additional parameters for file creation (e.g. a slug).

      Returns Promise<FileExt & WithResourceInfo>

      A Promise that resolves to the saved file, if available, or null if the current user does not have Read access to the newly-saved file. It rejects if saving fails.