Easiest way to update a pod?

I followed the “Make a Solid app on your lunch break!” tutorial and now I want to add/update/delete something on my pod. Can someone please provide me with a simple example of how to do this? I’m going round in circles reading forum posts and following links, so a simple example using JS or jQuery would be much appreciated. Thanks.

3 Likes

The structure of HTTP requests is described here: https://github.com/solid/solid-spec/blob/master/api-rest.md

It seems to me that there are tools to do this more easily but you can manipulate the resources on the pod with solid.auth.fetch

Here is an example to upload a file:

function createOrReplaceFile(url, data, dataType, cb) {

      solid.auth.fetch(url, {
        method: 'PUT',
        headers: {
          'Content-Type': dataType,
          'Link': '<http://www.w3.org/ns/ldp#Resource>; rel="type"',
        },
        body: data
        })
      .then(function(response) {
        // Some tasks
        return cb();
      });
};

Currently, there are two easy ways to manipulate data in your Solid Pod. The first is rdflib.js, and there’s some documentation on how to do this on the inrupt website.

However, rdflib.js can be very verbose in how it’s written for developers, with a bunch of overhead code. Because of this, a library for reading/writing data was created called LDFlex. LDFlex is not as well documented yet, but it’s a lot easier to use.

You can see some code examples of how to read/write data in the Solid React SDK. There are currently some undocumented functions, but the most documented use case is to simply read data which you can see on the github repo linked above. You can also use it to write/delete/edit data as well, in a very simple way.

There is a .set and .replace function, and a .delete function as well. You basically have to give it a subject and predicate to delete or fetch, and that’s more or less it. You can fetch more than one item using a for await loop as well.

2 Likes

ok thanks guys. I had a quick go with the example provided by @Hyuryu but i accidentally deleted everything in my pod lol. I’m not sure what to do about that. Anyway, i’ll have a look into LDFlex. cheers :wink:

1 Like

You could try to use solid-file-client a
npm package.

Or the apps solid-ide or solid-file-manager