Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
5
Erster Beitrag:
vor 1 Jahr, 4 Monaten
Letzter Beitrag:
vor 1 Jahr, 4 Monaten
Beteiligte Autoren:
Yogi Yang, PETER ZHOU, Fabrice Harari

[WM] - Download and save file in Mobile Storage

Startbeitrag von Yogi Yang am 31.03.2016 13:34

vello,

I am using following code to download file from web server using HTTPRequest and trying to save it to user selected location on phone. The code runs without any error but the file that gets saved is always of zero (0) byte.

Here is the code snippet that I am using:

nFID is int

HTTPRequest("http://xxxxxxxx.com/projects/sa/homework_file/"; + gsFileName)
sResult is Buffer = HTTPGetResult(httpResult)

IF Position(sResult,"404") THEN
Info(HTMLToText(sResult)) // or some other error handling to indicate the file was not found
ELSE
IF Length(sResult) > 0 THEN
nFID = fCreate(gsParentPath+gsFileName)
IF nFID > 0 THEN
Info(fWrite(nFID,sResult,Length(sResult)))
END
END
END
Info("File Saved")
Close()


Is there any mistake in the code?

Please help me here.

TIA

Yogi Yang

Antworten:

Hi

what is the content of gsParentPath?
Did you try with fSaveBuffer (that's what I'm using)?

Best regards

von Fabrice Harari - am 31.03.2016 14:48

Re: [WM] - Download and save file in Mobile Storage [Solved]

Oh how stupid of me.

The problem was in this condition:

IF nFID > 0 THEN // = 0 THEN
Info(fWrite(nFID,sResult,Length(sResult)))
END


von Yogi Yang - am 31.03.2016 14:53

Re: [WM] - Download and save file in Mobile Storage [Solved]

Hi Yogi,

>HTTPRequest("http://xxxxxxxx.com/projects/sa/homework_file/"; + gsFileName)

Do you need to enable the path under IIS to allow the HTTPRequest to download the file via WM ?

Regards,

PETER ZHOU

von PETER ZHOU - am 04.04.2016 04:43

Re: [WM] - Download and save file in Mobile Storage [Solved]

Hello,

The server from where I have to download the file and save is a Linux Server (CentOS).

TIA

Yogi Yang

von Yogi Yang - am 04.04.2016 05:38
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.