rejetto forum

How to allow POST file upload to non-existing path?

0 Members and 1 Guest are viewing this topic.

Offline nachum37

  • Occasional poster
  • *
    • Posts: 3
    • View Profile
Hi Everyone,

Sorry for my noob question. I have Data Logger that uploads CSV files to a predefined, unchangeable URL.
When I try to send the files to HFS, the log says that the server has disconnected. Using Wireshark I saw that HFS returns a 404 Not Found error.

Of course I set up an upload folder with the required permissions, and I manage to upload through the browser, and also with the Postman test. I guess, but I'm not sure, the problem here is that the device can't upload files by POST with a URL to a path that does not exist in advance, that looks something like:
(I turned here the slash so I could write the URL)

How do I enable the upload of files?

Is it necessary to write a script that will accept the call and generate the path? If so please please refer me to such example? Or in another way?

Thank you all.

Offline bmartino1

  • Tireless poster
  • ****
    • Posts: 903
  • I'm only trying to help i mean no offense.
    • View Profile
    • My HFS Google Drive Shared Link
How are you uiplading the file to HFS???

Are you going to hfs web page folder and clicking the uplaod button?

IF not, there is your problems.

Other wise we have to edit and chage some scritps to faciualt your needs by goin to a webpage selecting the file and uploading the data via a pst request:
*simple contact template has some solution for you to pull the code and re write.

you have to have these folder path in order to uplad adn the first - last folder having upload permision:

add a real folder to HFS > Righte mouse click > Protperties > permision tab > Upload tab > (set anyone for open folder to the web for upload.

7:42:21 AM Requested GET /Upload/
7:42:21 AM Requested GET /?mode=jquery
7:42:24 AM Requested GET /Upload/
7:42:24 AM Requested GET /?mode=jquery
7:42:44 AM Uploading lock pc.bat
7:42:44 AM Fully uploaded lock pc.bat - 40 @ 7.8 KB/s
7:42:44 AM Requested POST /Upload/
7:42:59 AM Requested GET /Upload/
7:42:59 AM Requested GET /?mode=jquery

see picture for result on client side to upload...
« Last Edit: April 04, 2019, 12:48:09 PM by bmartino1 »
Files i try to keep and share can be found on my google drive:

Offline nachum37

  • Occasional poster
  • *
    • Posts: 3
    • View Profile
Thank you for your answer.
upload via webpage upload button work perfectly.

I'm try to allow IoT Device upload automatically via POST HTTP Request, not manually via web page.
The Path, like DEVICE_UUID\signal_log\DATE\ is dynamically changed by the specific device and the date, is it impossible to create the path in advance and give him the permissions. i'm searching for the way to create the path by the URL of the POST request, or accept the file upload anyway to some directory, instead returning 404.

The path can be one of the following:



Offline LeoNeeson

  • Tireless poster
  • ****
    • Posts: 781
  • Status: On hiatus (sporadically here)
    • View Profile
Hi! :) this question is more for Mars, SilentPliz or Rejetto (than for me), but I could give you a possible "orientation". I'm not expert on macros, but I think this could be done by using HFS's macros. First, you should make (with a text editor) a file named "" (and save it along to "hfs.exe").

The contents of that "" could be something like (this is just a crazy theory, NOT actual working code):

Code: [Select]
{.if|{.header|{.is substring|POST|%item-resource%.}|{:
  {.if not|{.exists|%item-resource%.}|{:
    {.add to log|I've created the folder %item-resource%.}

» The idea is: read from the header of the POST HTTP Request, the destination folder. Then, if the destination folder doesn't exists, we create the folder. Keep in mind the code posted above is NOT working (the working script it's MUCH complex than that!).

» Another approach is 'somehow' (with a different macro script), when a folder doesn't exists, the file is uploaded to a temporary folder. Then, when the upload is completed, we create the desired folder (reading the destination folder from the original POST HTTP Request), and finally we move the uploaded file from the temporary folder to the new created folder.

(I hope someone else, expert on macros, could give you a hand)

Offline nachum37

  • Occasional poster
  • *
    • Posts: 3
    • View Profile
Hi Leo,
Thank you very much for your reply.

This is indeed what I wanted to find out, can I solve the problem by macro of HFS. I'm glad it's possible.

I will thank anyone who can direct me to the exact script that can be written.

Offline bmartino1

  • Tireless poster
  • ****
    • Posts: 903
  • I'm only trying to help i mean no offense.
    • View Profile
    • My HFS Google Drive Shared Link
so yes this can be macro coded. My curent working theory on the mater. as i don't have time to test and cod such a thing...

you will have to have Your iot device send the data via htmp Fake php strings... add url secondary data via a ? and post url red write data via & ...

This is why i also sent you to a working post method
i sent you leo simple contact template as that has the codes you will need to modify for the macro code/hfs side to accept the url string.


Hfs base line:
You will have to create a vitural folder in HFS

You will have to code a Macro script form

You wil lhave to setup the iot to talk to the vitural folder sending a url full string example:
(Pulled form a sucessful post of the url data sent to hfs via macro write - with is wht you would use to post upload)

you will send the requested data via example: /Contact/?name=Brandon+Martino&

so your sending data via the field on your virtual folder script.

decoding the example log and breakdown via url sending(the ### would be the data the iot device is sending...)

THis would be example of what your iot device making the request might look like

IOT would send something like this via your previos post

HFS setup:

the viturl folder can use a macro to take the field

and creat a realfolder via macro script
mkdir | A
creates the specified folder. URI is supported in A, but it must refer a real folder.

then uplaod the cvs file to hfs:

Code: [Select]
you could even skip some field formt eh form for the date.

this is the best i can do for yo on short notice
Files i try to keep and share can be found on my google drive: