Update one file in a folder (FilesContainer)

Is there an option to upload one file to replace an existing file within a FilesContainer that has many files?.. I keep defaulting to the files put upload all atm.

btw terminology seems odd at times… why do we talk of FilesContainer and not Folder or Drive?
dog and cat I get - because dogs fetch things right?.. erm :confused:

1 Like

Is there an option to upload one file to replace an existing file within a FilesContainer that has many files?.. I keep defaulting to the files put upload all atm

You can use safe files add with --force flag, eg:

$ safe files put --recursive testdata
FilesContainer created at: "safe://hnyynyzrs3xager3p9qazr3aatxqp5wyneo1racnxi8df1r3t8fwtwa1orbnc"
+  testdata/another.md              safe://hbhynydjthmxbrth4tkgrjki8mcihd5frigrz4yunw4rsjh31qhnaombg9 
+  testdata/noextension             safe://hbyyyydj99a5hm68szc3ehnt4swbo7caziod9w53b5j87efsykjqyxoo4k 
+  testdata/subfolder/sub2.md       safe://hbhynynt4oa3rihpop4sjppp3j5y59aa93a9ca7mqdkghg3mo9s76wgnis 
+  testdata/subfolder/subexists.md  safe://hbhynyn9dgh89nhe4o5sb4hs8n8csynq8qrjckf4nt8aqmkwa9uebhargk 
+  testdata/test.md                 safe://hbhynydjpor31taroabod6fugmbk5h9i4t7zz1edzu9oohrour9jogank8

$ safe files add testdata/another.md safe://hnyynyzrs3xager3p9qazr3aatxqp5wyneo1racnxi8df1r3t8fwtwa1orbnc/testdata/test.md --force
FilesContainer updated (version 1): "safe://hnyynyzrs3xager3p9qazr3aatxqp5wyneo1racnxi8df1r3t8fwtwa1orbnc?v=1"
*  testdata/another.md  safe://hbhynydjthmxbrth4tkgrjki8mcihd5frigrz4yunw4rsjh31qhnaombg9

btw terminology seems odd at times… why do we talk of FilesContainer and not Folder or Drive?
dog and cat I get - because dogs fetch things right?.. erm

Yeah, I’m unaware of all the history that led to present naming conventions. Perhaps others can comment. I would prefer to use terminology that people are more familiar with also.

Anyway, my goal now with CLI is to get basic PUT/GET operations fully functional for filesystem operations. Missing items on todo list include resolving recursive nrs urls, PUTing empty directories, hidden files, symlinks, metadata eg created/modified timestamps, and filtering by wildcard, ranges, and sets eg: *.jpg, photo{1-3}.jpg, photo{1,2,3}.jpg

5 Likes

It’s a good question but I think a sensible choice for now because those more familiar terms aren’t quite right either. Drives and folders can be implemented on top, but I think neither are accurate descriptions of a FilesContainer. Maybe ‘Container’ would be better to allow the files terminology/layer to sit aloof from it?

I might be wrong here though as I don’t know if there are plans to build on top of this or not. I have the impression the old NFS API which was closer to a filesystem API, is not going to be reconstituted at least for launch of MVP. Maybe later there will be a more filesystem like API, I don’t know.

Either way, it will be for apps or other libraries to provide something with terms like files and directories, and use the FileContainer to implement them. So good to provide a separation IMO.

Relatively few people will use the safe CLI in the longer term I think. Even CLI programs may provide a simplified UI for common operations.

Again I could be wrong. Predicting the future is not my strength!

2 Likes

Is the flag in question “–force” or “–recursive”? Or am I just being stupid?

1 Like

on the very right of the files add in the example is the --force flag. So, no surprises… the --recursive exampling the upload of many and the safe files add somefile --force doing the update to one.

1 Like

$ safe files put --recursive creates the file container. The --recursive flag recursively upload folders and files found in the source location.

Once the files container is created, modified files from source location can be automatically updated with $ safe files sync --recursive.

This synchronization is done globally in the files container. The OP asked how to update a single file in the files container. The answer to this is $ safe files add --force. Normally, this command creates a new file in the files container. The force --flag is needed to overwrite an existing file in the FilesContainer.

7 Likes

yes, what @tfa said. :slight_smile:

I should have put the --force force flag to left of url, so it wouldn’t scroll off the screen, eg:

safe files add --force <local_path> <container_url>
6 Likes

This topic was automatically closed after 60 days. New replies are no longer allowed.