rejetto forum

Send text file over http

celica · 14 · 6118

0 Members and 1 Guest are viewing this topic.

Offline celica

  • Occasional poster
  • *
    • Posts: 7
    • View Profile
Hi All
This is a fantastic piece of software.
I have an app which will send out data in text_binary or json format which will be one line of text normally (small file of roughly 8kb).

It will look something like this -

{source={ivarId={f1d22827-1650-41a0-a31e-28621430bc7d}, channel=1}, common={type=AUDIT_LOG, time=2020-04-20T15:40:11.256Z}, auditLog={clientId=2148, clientIp=127.0.0.1, account=, command=START_LIVE, parameters=[{name=channelId, value=1}, {name=answer, value=1}, {name=replyType, value=1}], result=STATUS_OK}, id={be138cc4-321c-41a9-8d2f-25a1e5d058fc}, addInfo={ivarIp=192.168.1.17}, images=[]}


The protocol it uses to send out is HTTP so i have to provide it a URL for which to send.
Would HTTP File Server work for this if I give it the IP?

« Last Edit: June 05, 2020, 12:46:09 PM by celica »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
welcome celica!
http is a client-server protocol, so you should specify if your app is going to be client or server.
if your app is client then surely you can make it work with HFS, otherwise not.


Offline celica

  • Occasional poster
  • *
    • Posts: 7
    • View Profile
Hello
It is a 3rd party app over which i have no control.
It will send out a subscription event via http as in the above format, i just need to capture it and save it somewhere so I thought this app would be perfect.

The app will run locally on the same PC as HTTP file server so just a local call is needed.

i just tried it there and I get this response:

1:58:00 PM 192.168.1.14:6505 Upload failed for b1177a2b-d043-45a9-a767-73caae8ea103_1_original.PNG: Not allowed.
1:58:00 PM 192.168.1.14:6505 Upload failed b1177a2b-d043-45a9-a767-73caae8ea103_1_original.PNG
1:58:00 PM 192.168.1.14:6506 Requested GET /aos/
1:58:07 PM 192.168.1.14:6515 Upload failed for a78c65a4-d735-4fa4-a714-60f5ad543c6c_1_original.PNG: Not allowed.
1:58:07 PM 192.168.1.14:6515 Upload failed a78c65a4-d735-4fa4-a714-60f5ad543c6c_1_original.PNG
1:58:07 PM 192.168.1.14:6516 Requested GET /aos/





Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
i don't know if HFS will be good for you, but you can try.
the first step to allow upload is to give upload permission.
if it is trying to upload to folder "aos" you will have to have this folder in the "virtual file system",  right-click, properties, upload, anyone.
Anyone is not good for security but it is a good start to see if it works.


Offline celica

  • Occasional poster
  • *
    • Posts: 7
    • View Profile
You're a genius, this has worked

2:13:34 PM 192.168.1.14:7424 Uploading b87e2514-6eb7-4966-abc7-8d03c8c3bc97_1_original.PNG
2:13:34 PM 192.168.1.14:7424 Fully uploaded b87e2514-6eb7-4966-abc7-8d03c8c3bc97_1_original.PNG - 194.7 K @ 918.4 KB/s
2:13:39 PM 192.168.1.14:7430 Requested GET /aos/
2:13:41 PM 192.168.1.14:7436 Uploading 13b817ff-53a4-4aa8-ba02-b0bcd5db84ef_1_original.PNG
2:13:41 PM 192.168.1.14:7436 Fully uploaded 13b817ff-53a4-4aa8-ba02-b0bcd5db84ef_1_original.PNG - 128.0 K @ 4.8 MB/s
2:13:41 PM 192.168.1.14:7437 Requested GET /aos/


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
i'm glad.
i see that you are in a LAN, so if you know that your server is not accessible via internet you may consider to leave the 'anyone', if you trust your LAN users.

to know if the server is accessible iva internet you can use the Menu>self test.
If it fails then you work only in LAN.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2063
    • View Profile
i don't know if HFS will be good for you, but you can try.
the first step to allow upload is to give upload permission.
if it is trying to upload to folder "aos" you will have to have this folder in the "virtual file system",  right-click, properties, upload, anyone.
Anyone is not good for security but it is a good start to see if it works.


The protocol it uses to send out is HTTP so i have to provide it a URL for which to send.
Would HTTP File Server work for this if I give it the IP?


it is therefore possible to authorize an on upload account for the real file and to integrate user and password in url

otherwise according to the method of sending data, if they can be done in text mode and not binary, then as much integrate them either in the url or in the form of a form.

for security reasons this data would be processed in a specific section placed in a diff template of the folder hidden in the tree structure, the data processed by the script may be saved after appropriate processing in one or more files as required with names different

the folder can also be protected in access, for only the previous account and the persons authorized to deal with it, thus preserving any risk of intrusion by an anonymous person
« Last Edit: June 05, 2020, 02:49:42 PM by Mars »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
if the requests will always come from 192.168.1.14
you can set a ban rule like this: \192.168.1.14
the initial \ will allow only that address to make requests.
I would consider this secure enough.

Menu > limits > bans


Offline celica

  • Occasional poster
  • *
    • Posts: 7
    • View Profile
Yes, I'll do that.
Whats weird is it should send the image (which it does) and a text file depicted the event status.

You can see below the image gets received fine but no text file.
I wonder is the "Requested GET" is it atttempting to send the text file.

6:59:53 PM 192.168.1.14:24976 Uploading a60dd80b-db6d-4dbe-becb-c057c5d86ffa_1_original.PNG
6:59:53 PM 192.168.1.14:24976 Fully uploaded a60dd80b-db6d-4dbe-becb-c057c5d86ffa_1_original.PNG - 210.9 K @ 4.9 MB/s
6:59:53 PM 192.168.1.14:24977 Requested GET /aos/
7:01:45 PM 192.168.1.14:25210 Requested GET /aos/
7:01:50 PM 192.168.1.14:25221 Requested GET /aos/


Offline celica

  • Occasional poster
  • *
    • Posts: 7
    • View Profile
So i enabled - Debug - Dump Traffic and within this file hfs-dump.bin is the text I need, hfs-dump is stored in Downloads folder
I'm not sure why a JSON file is not created in the upload folder.
Instead the only way I can access the JSON data is by viewing the traffic log above.

You can see the contents here:
Is there any way to save the data below to the upload folder?

Code: [Select]
[i]
   " 
      ÄÉœ™zå@        192.168.1.15       6241
   ê  POST /aos HTTP/1.1
Host: 192.168.1.15
User-Agent: python-requests/2.18.4
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Content-Type: application/json
Authorization: Basic Og==
Content-Length: 775

{"id": "{a87ad5c8-1dcf-4df6-84e7-9b022e02ea24}", "source": {"channel": 1, "bacId": "{f9e8c4c5-9b8f-8419-f9e8-c4c59b8f8419}", "taskId": "{6cdac414-95d0-457c-a98a-8b5898dc692b}", "ivarId": "{f1d22827-1650-41a0-a31e-28621430bc7d}"}, "common": {"description": "Intelligent Object Detection", "presentImageTime": "2020-06-06T18:12:30.629Z", "subtype": "FD", "time": "2020-06-06T18:12:30.629Z", "type": "IOD"}, "imagesV2": {}, "iodV2": {"age": "ADULT", "errorMessage": "", "faceAvailable": true, "frSuitable": "NA", "gender": "MALE", "glasses": "REGULAR", "groupId": 0, "liveness": "NO_RESULT", "livenessProbability": "0.0000", "mask": "NONE", "objectId": 20, "objectType": "FACE", "occlusion": "NA", "race": "NA", "ageRange": {"from": 25, "to": 32}, "colors": {"colorNumber": 0}}}   " 
      I!Êœ™zå@        192.168.1.15       6241
   ê  POST /aos HTTP/1.1
Host: 192.168.1.15
User-Agent: python-requests/2.18.4
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Content-Type: application/json
Authorization: Basic Og==
Content-Length: 775

{"id": "{a87ad5c8-1dcf-4df6-84e7-9b022e02ea24}", "source": {"channel": 1, "bacId": "{f9e8c4c5-9b8f-8419-f9e8-c4c59b8f8419}", "taskId": "{6cdac414-95d0-457c-a98a-8b5898dc692b}", "ivarId": "{f1d22827-1650-41a0-a31e-28621430bc7d}"}, "common": {"description": "Intelligent Object Detection", "presentImageTime": "2020-06-06T18:12:30.629Z", "subtype": "FD", "time": "2020-06-06T18:12:30.629Z", "type": "IOD"}, "imagesV2": {}, "iodV2": {"age": "ADULT", "errorMessage": "", "faceAvailable": true, "frSuitable": "NA", "gender": "MALE", "glasses": "REGULAR", "groupId": 0, "liveness": "NO_RESULT", "livenessProbability": "0.0000", "mask": "NONE", "objectId": 20, "objectType": "FACE", "occlusion": "NA", "race": "NA", "ageRange": {"from": 25, "to": 32}, "colors": {"colorNumber": 0}}}   " 
      $:Êœ™zå@        192.168.1.15       6241
   ê  POST /aos HTTP/1.1
Host: 192.168.1.15
User-Agent: python-requests/2.18.4
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Content-Type: application/json
Authorization: Basic Og==
Content-Length: 775

{"id": "{a87ad5c8-1dcf-4df6-84e7-9b022e02ea24}", "source": {"channel": 1, "bacId": "{f9e8c4c5-9b8f-8419-f9e8-c4c59b8f8419}", "taskId": "{6cdac414-95d0-457c-a98a-8b5898dc692b}", "ivarId": "{f1d22827-1650-41a0-a31e-28621430bc7d}"}, "common": {"description": "Intelligent Object Detection", "presentImageTime": "2020-06-06T18:12:30.629Z", "subtype": "FD", "time": "2020-06-06T18:12:30.629Z", "type": "IOD"}, "imagesV2": {}, "iodV2": {"age": "ADULT", "errorMessage": "", "faceAvailable": true, "frSuitable": "NA", "gender": "MALE", "glasses": "REGULAR", "groupId": 0, "liveness": "NO_RESULT", "livenessProbability": "0.0000", "mask": "NONE", "objectId": 20, "objectType": "FACE", "occlusion": "NA", "race": "NA", "ageRange": {"from": 25, "to": 32}, "colors": {"colorNumber": 0}}}   

      jËœ™zå@        192.168.1.15       6242
   Ò   GET /aos/ HTTP/1.1
Host: 192.168.1.15
User-Agent: python-requests/2.18.4
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Authorization: Basic Og==
Cookie: HFS_SID_=0.779310089536011

   

      æÇÕœ™zå@        192.168.1.15       6242
   Ò   GET /aos/ HTTP/1.1
Host: 192.168.1.15
User-Agent: python-requests/2.18.4
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Authorization: Basic Og==
Cookie: HFS_SID_=0.779310089536011

   

      ±ïØœ™zå@        192.168.1.15       6242
   Ò   GET /aos/ HTTP/1.1
Host: 192.168.1.15
[/i]


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
You can see below the image gets received fine but no text file.
I wonder is the "Requested GET" is it atttempting to send the text file.
7:01:50 PM 192.168.1.14:25221 Requested GET /aos/

since aos is a folder, Requested GET /aos/
represents a request for the listing of the files of the folder.

from the other information you posted i see the upload is done using a different method that's not compatible with HFS, which uses the format used by standard browsers' forms.


Offline celica

  • Occasional poster
  • *
    • Posts: 7
    • View Profile
That's a shame I cant use HFS
Would you know of any other software that could accept the JSON data?


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
the point is not the JSON, but the WAY it is sent.
HFS accepts any file format, it doesn't care, just saves it.
In your case it is not sent as a file, indeed no filename is included.
The way I see it, who made that client surely also made the server part. Ask him/her.
Otherwise I don't know if you'll find a software to do what you want. If you don't, find a good php (or python) (or node.js) programmer to build a solution for you. Looks like a 1-hour job.
« Last Edit: June 07, 2020, 10:34:30 AM by rejetto »


Offline celica

  • Occasional poster
  • *
    • Posts: 7
    • View Profile