You might want to use Solid-File-Client which handles reading and write of resources including non-RDF resources like photographs with higher level methods such as fc.createFile(URI,content,content-tyep) which handles the details of PUT and POST behind the scenes. If you are going to do this manually with solid-auth-client then you need to learn more about how POST works. A POST should send the URI of the parent container, not of the image file. The name of the image file belongs in the slug field of the POST, not the URI field.
This URL appears to be missing something before .inrupt.net. Is the error message you posted correct, and if so, could you check the values of this.baseUrl and session.webId?
I’ve also tried to use solid-file-client lib but to no avail.
There was no way to make it work. Kept complaining about not having a constructor.
import { SolidFileClient } from 'solid-file-client';
private async prepareBaseUrl() {
if (this.baseUrl && this.fc) {
return;
}
this.fc = new SolidFileClient(this.solidAuthService); // Error Here saying that no constructor is available
// (tried different ways of importing it but to no avail)
const session = await this.solid.currentSession();
const webIdUrl = new URL(session.webId);
this.baseUrl = `${webIdUrl.protocol}//${webIdUrl.hostname}`;
}
I’m using Typescript on an Angular app.
What I had was pretty much the same. Looks different because of the “auth” service, but I’ll give it another try since it will make things much easier to develop and maintain.
I don’t think that there’s a type definition for solid-file-client on DefinitelyTyped.
It would be nice to have the type defined for easier Typescript integration.
Installation would be as easy as:
npm install @Types/solid-file-client
Something for the thought. After looking at the solid-file-client code, the API seems to be quite simple and straight forward, so, it shouldn’t take long to add type support for Typescript.