What is the easiest way to read a file written with Delphi Streamfile with Webcore.
Stream := TFileStream.Create(DataDir + 'data\data1.str', fmCreate);
len := SizeOf(Recordx);
Stream.WriteBuffer(len,8); // write len Record
Stream.WriteBuffer(Projekt.Dp, len); // write Record
WebCore Code -- but not possible
Stream := TBytesStream.Create;
Have you tried a TMemoryStream?
If you load the file (if this is a local file, you need a file picker for this), you can assign the TJSArrayBuffer retrieved from the file picker to TMemoryStream.Memory and then read from it.
The file is on the server.
until now i'm doing that by converting to string and then reading into WebMemo.
WebMemo.Lines.LoadFromFile ('data \ webhmi.ini');
But I have to change everything back again, which doesn't necessarily make sense.
With a stream, I could read the entire record at once without conversion.
At stream level, there is at this moment not a LoadFromFile() method.
You could get the file contents using a TWebHttpRequest.
It is an interesting suggestion to have a LoadFromFile() and we've added this on the list for consideration.
this has already been solved
I need to interpret a serial file that is on a server.
something like "LoadFromFileToByteArray()" or "SaveToFileFromByteArray()"
If you use TWebHttpRequest, set ResponseType to rtArrayBuffer and then perform a GET request.
Then, in the OnRequestResponse event handler, you should be able to cast the ARequest.req.response to a TJSArrayBuffer and use this data returned.
Thanks for the tip: works fine
now I have a new problem.
What do I have to do to have only the "index.html" and maybe the "xxx.js" file in the route and all other files generated by TMS in a subdirectory?
The hardware on which the web server runs has div. directories. One of them was "webhmi" and under this directory the whole TMS web project was deployed. The webserver was also set to this directory. So the "index.html" was started from the "webhmi" directory.
Now it has a file in the directory "data "which I should read with this TWebHttpRequest.
But this only works if the webserver-path points directly to the route-directory, so I can access all directories.
Now the access works.
But now I have the problem that all files generated by TMS are in this route , which is not nice.
Can I put these files back into the webhmi directory except the "index file" ?
And where can I set the path in the JS for the generated files from TMS.
all files I load myself at runtime I could put back into the "webhmi" directory where I added the access with "\webhmi", but I can't do that with the files generated by TMS.
It is assumed that all form .HTML files are in the same folder as these HTML files are loaded by the framework with relative filenames. So, the root project HTML file (index.html) and the form HTML files are assumed to be in the same folder.
If you need to access a file in a folder data above this app subfolder, you should be able to access that with an absolute server path URL.
how do i specify the absolute server path URL?
this does not work
[HTTP/1.1 404 Not Found 14ms]
Status 404 Not Found
Übertragen 226 B (156 B Größe)
my structure looks like this:
WebServer path set to
webhmi so that all web files are under webhmi
I can't read the files under data.
My attempts look like this:
the same with error files in root
once i have the files under
root://webhmi i can read them.
that's all it takes
What exactly do I have to do that the access to
In my opinion this does not work at all, because I have the root of the webserver on
i can't go back on the path tree than the "webserver root"
in my case
Can't the browser access
If the browser itself cannot access this, I can only suspect there is a config issue on your webserver that it doesn't make this file accessible.
whtRequest.URL := 'http://192.168.200.67/data/error1.his';
this.whtRequest.FURL = "http:\/\/192.168.200.67\/data\/error1.his";
[HTTP/1.1 404 Not Found 8ms]
If you get a 404, the web server doesn't offer access to the file, so it is a web server config issue.
If I change the web server root directory from
root:// can access
but then I have all webfiles in the
root:// which I don't want this
until now I have found no settings where I can change this
I can only set the web server root path
In that case this is a server config issue. If you will want to the web app to access the files under data, the files should be made accessible in the web server config.