rejetto / hfs

HFS is a web file server to run on your computer. Share folders or even a single file thanks to the virtual file system.
GNU General Public License v3.0
2.29k stars 227 forks source link

Does hfs support uploading files through api, and uploading files must pass authentication #586

Closed ilanni2460 closed 6 months ago

ilanni2460 commented 6 months ago

Does hfs support uploading files through api, and uploading files must pass authentication

rejetto commented 6 months ago

yes, it does. Refer to https://hfs-3.apidog.io/

rejetto commented 6 months ago

for authentication you can use standard http authentication, possibly with https to avoid clear-text passwords

ilanni2460 commented 6 months ago

@rejetto Thank you very much for your reply. I used the following method to upload files, but still got an error.

curl -X POST --header 'x-hfs-anti-csrf: 1' -u "admin:P@qqq" -H "Content-Type: application/octet-stream" --data-binary "@/root/a.txt" http://127.0.0.1/soft/ Use this method to report an error,this log: Bad Request

rejetto commented 6 months ago

thanks for reporting! i will now update the documentation to specify that POST requires multipart, while PUT doesn't. Refer to this to know correct usage with curl https://github.com/rejetto/hfs/wiki/Upload#from-command-line

ilanni2460 commented 6 months ago

@rejetto OK, all right. By the way, I would like to ask again, how to overwrite existing files when uploading through API

rejetto commented 6 months ago

do you want all uploads to always overwrite?

ilanni2460 commented 6 months ago

@rejetto I will cover it often。always overwrite。

rejetto commented 6 months ago

then you may want to just change this option

image

otherwise, you can see that i just updated API documentation to include overwrite

ilanni2460 commented 6 months ago

@rejetto Thank you very much, that's definitely covered.

ilanni2460 commented 6 months ago

@rejetto

This is my command to upload files. Because the authentication method is not enabled, I achieve the purpose by setting the access permissions of the directory. Everyone can upload it, and only designated people can view/modify and delete it.

curl -F upload=@a.txt http://192.168.70.193/soft/software_list/

1

rejetto commented 6 months ago

you don't need authentication, or you can't make it work?

ilanni2460 commented 6 months ago

@rejetto Haha, it doesn't matter. I don't upload files through authentication now. I can achieve my purpose by just specifying the access rights to the directory. Thank you very much for your timely answer.