#38 Directory support

Otevřený
otevřeno před 3 roky uživatelem farooqkz · 0 komentářů

Planned APIs(will probably change over time...)

add directory (Admin)

/add_dir?path=dir/subdir&create_parents=y
/add_dir?path=dir/subdir
  • create_parents(defaults to empty string) if present and equal to non empty string will make PotatoEgg make parent directories of the subdir(if it has one and if it does not exist) as well. Without this argument /add_dir will through back an error message indicating parents do not exist.

Remove directory (Admin)

/delete?name=path/to/directory
/delete?name=path/to/directory&confirm=somecode
/delete/name=/&confirm=somecode

/delete acts normally if it is path to some file but if it is directory, will not delete it in the first place, instead will message the user with a confirmation code. Once the user enters the confirmation code and it is correct, the directory will be removed recursively(e.g. the directory including all files and sub-directories inside it will be deleted) and the confirmation code will be discarded immediately.

/delete also "works" for the root directory but does not remove the root directory since the app will break. Rather /delete clears all its contents. Another difference is that for admin must confirm this action twice using confirmation codes(or how about confirming just once and asking for admin's password instead?)

Accessing directories

/?dir=somedir
/

dir defaults to / when not specified and index page should contain a .. entry in all directories(including or excluding root?) which user goes to the parent directory by clicking on it(for root if present will go to root again)

Just like hidden files(starting with a dot) which are accessible only for admin, hidden directories are also alike. Regular users will NEVER be able to access a hidden directory in any way!

We should also change the mustache template to use dir to set arguments for other pages like /delete or /hashsum

Upload from storage

/upload?...&path=somedir
/upload?...

path defaults to root directory if not specified and /upload will upload all files to there. If the specified directory does not exist, responses with an error message regarding that.

Upload from Web

Just like before but it acts a bit differently:

  • If name is just a filename(e.g. file.zip), file will be saved to root with that name.
  • If name is a directory name(e.g. dir/anotherdir), the file will be saved to that directory with its original name
  • If name if a full path (e.g. dir/file.zip) the file will be downloaded, saved in dir with name file.zip.
  • If name is omitted, the file will be saved in root with its original name.

In the case in which user don't specify a name for the file, PotatoEgg will save file with its original name if the HTTP(S) server provide one or a random numeric name if HTTP(S) server didn't.

In the case in which a file with the same name exists in PotatoEgg storage and in the said directory, PotatoEgg will override that file!

In all cases, the trailing slash will be removed (if any). The type of said file(being a regular file or directory) makes PotatoEgg decide what to do NOT the trailing slashes.

It is up to templating to create buttons in the page which upload to the current directory.

Setting password for directories?

I should think about it and I am not sure if we need this. Also if planned it won't be added in version 2, rather version 3 or higher.

### Planned APIs(will probably change over time...) #### add directory (Admin) ``` /add_dir?path=dir/subdir&create_parents=y /add_dir?path=dir/subdir ``` - `create_parents`(defaults to empty string) if present and equal to non empty string will make PotatoEgg make parent directories of the subdir(if it has one and if it does not exist) as well. Without this argument `/add_dir` will through back an error message indicating parents do not exist. #### Remove directory (Admin) ``` /delete?name=path/to/directory /delete?name=path/to/directory&confirm=somecode /delete/name=/&confirm=somecode ``` `/delete` acts normally if it is path to some file but if it is directory, will not delete it in the first place, instead will message the user with a confirmation code. Once the user enters the confirmation code and it is correct, the directory will be removed recursively(e.g. the directory including all files and sub-directories inside it will be deleted) and the confirmation code will be discarded immediately. `/delete` also "works" for the root directory but does not remove the root directory since the app will break. Rather `/delete` clears all its contents. Another difference is that for admin must confirm this action twice using confirmation codes(or how about confirming just once and asking for admin's password instead?) #### Accessing directories ``` /?dir=somedir / ``` `dir` defaults to `/` when not specified and index page should contain a `..` entry in all directories(including or excluding root?) which user goes to the parent directory by clicking on it(for root if present will go to root again) Just like hidden files(starting with a dot) which are accessible only for admin, hidden directories are also alike. Regular users will NEVER be able to access a hidden directory in any way! We should also change the mustache template to use `dir` to set arguments for other pages like `/delete` or `/hashsum` #### Upload from storage ``` /upload?...&path=somedir /upload?... ``` `path` defaults to root directory if not specified and `/upload` will upload all files to there. If the specified directory does not exist, responses with an error message regarding that. #### Upload from Web Just like before but it acts a bit differently: - If `name` is just a filename(e.g. `file.zip`), file will be saved to root with that name. - If `name` is a directory name(e.g. `dir/anotherdir`), the file will be saved to that directory with its original name - If `name` if a full path (e.g. `dir/file.zip`) the file will be downloaded, saved in `dir` with name `file.zip`. - If `name` is omitted, the file will be saved in root with its original name. In the case in which user don't specify a name for the file, PotatoEgg will save file with its original name if the HTTP(S) server provide one or a random numeric name if HTTP(S) server didn't. In the case in which a file with the same name exists in PotatoEgg storage and in the said directory, PotatoEgg will **override** that file! In all cases, the trailing slash will be removed (if any). The type of said file(being a regular file or directory) makes PotatoEgg decide what to do NOT the trailing slashes. It is up to templating to create buttons in the page which upload to the current directory. #### Setting password for directories? I should think about it and I am not sure if we need this. Also if planned it won't be added in version 2, rather version 3 or higher.
Přihlaste se pro zapojení do konverzace.
Načítání...
Zrušit
Uložit
Není zde žádný obsah.