Filestore is a simple file store service that stores plain-text files (HTTP server and a command line client)
- Python version >= 3.8
It is recommended that you use a python virtual environment to install the necessary dependencies in both client and server. Do below steps on both server and cient
- Clone filestore repository from
https://github.com/vavuthu/filestore
via cmd
git clone https://github.com/vavuthu/filestore.git
or
git clone [email protected]:vavuthu/filestore.git
. - Go to filestore folder
cd filestore
. - Setup a python 3.8 virtual environment.
python3.8 -m venv <path/to/venv>
source <path/to/venv>/bin/activate
- Install requirements with
pip install -r requirements.txt
Note: Follow above steps in both client and server
- Once virtual environment is activated and installed requirements.txt from above steps,
go to any directory which we would like to act as file store and start the httpd server
using below command. By default it will run on port 8000
run-server
Edit the .env file in filestore repository and add the server URL. Incase you are running httpd server locally, no need to edit the file. example: If httpd server is running on 10.x.xxx.xxx, .env looks like below
$ cat .env
URL=http://10.x.xxx.xxx:8000/
Once virtual environment is activated and installed requirements.txt from above steps,
use store
command to perform file operations like ls, add, etc. Few example are below for reference
Uploads multiple files to server.
- add multiples files to server
$ store --add file1 file2
file1 uploaded successfully
file2 uploaded successfully
- add multiples files with few files already existed in server (skips the upload of existing files)
$ store --add file1 file3 file4
file1 exists in server. skipping upload...
file3 uploaded successfully
file4 uploaded successfully
- add files having same content present in server ( create files in server without sending contents to server)
$ store --add dup
dup is duplicate of file3 in server
created dup without sending contents over network
- add file to file store which doesn't have write permissions
$ store --add file1
Upload failed, please check permissions on file store
List all the files in server
$ store --ls
file1
file2
file3
file4
dup
Remove files from server
- remove multiple files from server
$ store --rm file1 file2
- remove a file which doesn't exist on server
$ store --rm file1
Error: file1 - No such file or directory
Updates file on server, if file doesn't exist it will create new file
- update file
$ store --update updatefile1
updatefile1 updated successfully
- update file having contents same on server
$ store --update file1_dup
file1_dup is duplicate of file1 in server
updated file1_dup without sending contents over network
- update the file having same filename and contents on server. It will update metadata of file
$ store --update file1
file1 is duplicate of file1 in server
updated metadata for file1 since filename and content are same
Count the number of words on all files in file store
$ store --wc
Total number of words in all files are 8
List the most frequent words in all the files combined. We can list by either limit (default limit is 10) and order (dsc or asc, default value is dsc(descending))
- List most frequent words by default values
$ store --freq_words
data : 19
openshift : 14
and : 13
foundation : 11
the : 10
red : 9
hat : 9
for : 9
cluster : 7
to : 7
- List most frequent words by limit
$ store --freq_words --limit 3
data : 19
openshift : 14
and : 13
- List most frequent words by order
$ store --freq_words --limit 3 --order asc
rhacm : 1
requirements, : 1
detailed : 1