Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Saving a file Locally
Fri, May 29 2020 6:31 PMPermanent Link

KimHJ

Comca Systems, Inc

I'm trying to find out how I can save a text file to a local folder after receiving it from the web server.

I found a post back from 2012 where @Matthew Jones say he used TLink. I have looked at the TLink, but I can not see how it was used to save the file.

Since 2012  is there another way to save a file to the local computer?

Thanks,
Kim
Wed, Jun 3 2020 3:28 AMPermanent Link

Matthew Jones

KimHJ wrote:

> I'm trying to find out how I can save a text file to a local folder after receiving it from the web server.

You won't be able to do it without the user getting involved somehow, or at least it being put in a "downloads" folder automatically. If you want to be able to handle the content in your application, then you'd use a TServerRequest and use the content. But direct to disk is considered a security issue nowadays.


--

Matthew Jones
Wed, Jun 3 2020 2:45 PMPermanent Link

KimHJ

Comca Systems, Inc

"Matthew Jones" wrote:

>You won't be able to do it without the user getting involved somehow, or at least it being put in a "downloads" folder automatically. If you want to be able to handle the content in your application, then you'd use a TServerRequest and use the content. But direct to disk is considered a security issue nowadays. <

Matthew,

It's a TServerRequest  and the text file in is Request.ResponseContent.Values['printfile'].
Since I can't send it direct to a receipt printer I will have to save it to disk and then a local program will print it.
So there is no way to save to a local disk?

Kim
Thu, Jun 4 2020 11:09 AMPermanent Link

Bruno Larochelle

As Matthew mentioned, if the user gets involved it is possible.

Erick Engelke's book has a section on this. He uses the external library 'filesaver.js'.

I have tried this, and it works. I prompt the user for a filename, and the browser then downloads that to a local file.

I am not a security expert, so others can chime in if this technique is of concern.

Regards.. Bruno


KimHJ wrote:

"Matthew Jones" wrote:

>You won't be able to do it without the user getting involved somehow, or at least it being put in a "downloads" folder automatically. If you want to be able to handle the content in your application, then you'd use a TServerRequest and use the content. But direct to disk is considered a security issue nowadays. <

Matthew,

It's a TServerRequest  and the text file in is Request.ResponseContent.Values['printfile'].
Since I can't send it direct to a receipt printer I will have to save it to disk and then a local program will print it.
So there is no way to save to a local disk?

Kim
Fri, Jun 5 2020 8:53 AMPermanent Link

Matthew Jones

If you can have the server send it as a PDF then you can probably have them view it for printing. This becomes standard html/javascript stuff, so Google will tell you what options you have.


--

Matthew Jones
Thu, Jun 11 2020 4:34 PMPermanent Link

KimHJ

Comca Systems, Inc

"Matthew Jones" wrote:

>>If you can have the server send it as a PDF then you can probably have them view it for printing. This becomes standard html/javascript stuff, so Google will tell you what options you have.

Matthew
It's a receipt printer I can't send a PDF file to a receipt printer.
I have Erick Engelke's book I will try the JavaScript.

Kim
Image