Announce : much updated Solid-File-Client

After many months of work, @bourgeoa, @A_A , and I are releasing version 1.0.0 of Solid-File-Client. This library of methods to manage Solid files and folders now has the ability to copy or move entire folder trees from one pod to another or back and forth between a pod and a local file system. It supports both text and binary files and works in either a browser or node/console context. Also new in this version is extensive support for linked resources (.acl and .meta files). By default linked resources are copied, moved, and deleted with their associated resource, but options allow you to adjust that behavior as well as to discover the location of linked resources.

There are a number of changes which are not backward compatible. Users of the old version of Solid-File-Client should see Transitioning to Version 1.x.

Here is a complete working node script to upload and download images to and from your current local working directory. Also take a look at the Browser Upload Demo which allows you upload to your pod without even having to install Solid-File-Client.

const auth = require('solid-auth-cli') 
const FileClient = require('solid-file-client')
const fc = new FileClient(auth)

const remoteBase = "https://jeffz.solid.community/public/"
const localBase  = "file://" + process.cwd() + "/"  // current working folder
const local   = localBase + "square.png"
const remote  = remoteBase + "square.png"
const local2  = localBase + "square2.png"
const remote2 = remoteBase + "square2.png"

async function run(){
    try {
        await auth.login()
        await fc.copyFile( local,  remote )   // upload
        await fc.copyFile( remote, local  )   // download
        await fc.copyFile( remote, remote2 )  // copy btwn remote locations
        await fc.copyFile( local,  local2  )  // copy btwn local locations
    }
    catch(err) {
        console.log(err)
    }
}
run()

If you have questions, feel free to ask in the forum or on gitter. For bug reports or feature suggestions, please use github issues and PRs. If you don’t know how to do that, ask! :slight_smile:

Enjoy!

14 Likes

It looks amazing, congrats on the release!

1 Like

Thanks, great work

1 Like

Jeffz Strikes again! Great Job Jeff!!!

1 Like

I just tried the Browser upload, but it does not work

  • Login button does nothing
  • Errors occur in the browser console:
index.js:3 Uncaught ReferenceError: require is not defined
    at index.js:3
(anonymous) @ index.js:3
index.min.js:7 Uncaught SyntaxError: Cannot use import statement outside a module
(index):133 Uncaught ReferenceError: SolidFileClient is not defined
    at (index):133
(anonymous) @ (index):133

How do I copy ACLs? I tried copying a folder containing a .acl file but, it broke the folder and I am now only getting this message:

Error: Don't know how to parse text/plain yet while trying to parse <https://pod-homepage.solid.community/static/.acl> as text/plain

That is very odd. Can you show me the code that produced that? The .acl was working okay before the copy?

Sorry, did the demo at the last minute, I’ll check it.

Yes, it worked before, I did:

await fc.copyFolder(src, target, { merge: 'keep_source' });

where src is a folder on my local file system, containing just a .acl file and target is a respective folder on my pod.

All right , the demo should work again now (on github, haven’t npm’d yet). Looking into the .acl thing.

I can not reproduce your .acl problem. I created a folder on my local system, added a single .acl file there (a copy of my public folder’s .acl), copied the folder to my pod using the same command you did and it worked fine. I then recopied over the now-existing folder on the pod and it still worked fine. What was the command which produced the error you showed (Don’t know how to parse text/plain)?

The message shows up when opening the folder in the browser. I will prepare a reproducable example

1 Like

I could not reproduce it in a clean setup either and thereby found out, that I had no explicit installation of solid-auth-cli in my project. After installing this, it works now.

Thanks for your support and the great work!

1 Like

Phew! You had me scared. Thanks much for testing and reporting!

1 Like

No worries, I have more :smiley:

When copying index.html to the Pod root I am getting an error

The command:

await fc.copyFile(
            'file://' + process.cwd() + '/build/index.html',
            'https://pod-homepage.solid.community/index.html'
        );

Output:

b [SFCFetchError]: SFCFetchError Cannot read property 'endsWith' of undefined
    at toFetchError (/path/to/projet/node_modules/solid-file-client/dist/node/solid-file-client.bundle.js:8:66451)
    at /path/to/projet/node_modules/solid-file-client/dist/node/solid-file-client.bundle.js:8:68384
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async $.copyLinksForItem (/path/to/projet/node_modules/solid-file-client/dist/node/solid-file-client.bundle.js:8:71869)
    at async $.copyFile (/path/to/projet/node_modules/solid-file-client/dist/node/solid-file-client.bundle.js:8:70853)
    at async run (/path/to/projet/upload.js:10:9) {
  name: 'SFCFetchError',
  successful: [],
  rejected: [],
  rejectedErrors: [],
  errors: [
    TypeError: Cannot read property 'endsWith' of undefined
        at $.copyFile (/path/to/projet/node_modules/solid-file-client/dist/node/solid-file-client.bundle.js:8:70642)
        at $.copyMetaFileForItem (/path/to/projet/node_modules/solid-file-client/dist/node/solid-file-client.bundle.js:8:71019)
        at processTicksAndRejections (internal/process/task_queues.js:97:5)
        at async $.copyLinksForItem (/path/to/projet/node_modules/solid-file-client/dist/node/solid-file-client.bundle.js:8:71869)
        at async $.copyFile (/path/to/projet/node_modules/solid-file-client/dist/node/solid-file-client.bundle.js:8:70853)
        at async run (/path/to/projet/upload.js:10:9)
  ],
  ok: false,
  message: "SFCFetchError Cannot read property 'endsWith' of undefined",
  status: -1,
  statusText: "SFCFetchError Cannot read property 'endsWith' of undefined"
}

The actual upload process did work nevertheless. Seems to be a follow up error.

OK, thanks, I’ll look into it. Did you have an index.html.meta or index.html.acl in the folder you copied from?

No source folder only contains index.html. I tried both copyFile and copyFolder. It works, if I do not copy to the pod root

Thanks, I’m guessing it’s some kind of edge case with the pod root.

I’ll keep looking for this although it’s cosmetic. If (or should I say when) you find other things, would you mind submitting an issue rather than posting here - makes it much easier for me to track and follow up.

Yes of course, I just wanted to make sure its a real issue. Will use github from now on.

I think its not just cosmetic, because it throws an exception and will break the regular code flow, i.e. anything that relys on successful copy operation will not execute, though it actually was kind of successful