Skip to content
⌘ NSIS Forum Archive

http + ftp download plug-in

545 posts

morty3#
Hi Takhir,

thanks for the quick reply. The first URL works with my script too, it is the second and third URL that don't work.
Takhir#
Sorry 🙂
Please test last link (https) in a browser - my Mozilla displays "Download Java SE Development Kit 6u17 for Solaris x86, Multi-language" page, not exe. The same I get from inetc - 28 kB file, when renamed it is viewable in borwser as well.
StephanB86#
Still got some problems using ftp:😛ut

When using:
Works:
inetc:😛ut /CAPTION "service pack upload" "ftp://user😛ass@192.168.0.150:8021/5mb.bin" "c:\Dell\5mb.bin"

Fails:
inetc:😛ut /CAPTION "service pack upload" "ftp://user😛ass@192.168.0.150:8021/Application/5mb.bin" "c:\Dell\5mb.bin"

The only difference is the Directory on the FTP server. The directory exists. What else should I use?
StephanB86#
I know. But logging on with any other FTP client is placed in to root. Local FTP server that's running on a device with WinCE. For testing purposes it's running localy.
By running the working version it's placed in the root correctly. And I'm really sure that the directory exists 🙂
StephanB86#
Current user gots al the permissions he need. I get the Reget error. Any example?
Or just like:
inetc:😛ut /CAPTION "service pack upload" "ftp://user😛ass@192.168.0.150:8021//Application/NewDir/5mb.bin" "c:\Dell\5mb.bin"
Takhir#
This work for me

;--------------------------------
; General Attributes

Name "Inetc ftp mkdir Test"
OutFile "ftp_mkdir.exe"


;--------------------------------
;Interface Settings

!include "MUI.nsh"
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install-colorful.ico"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"


;--------------------------------
;Installer Sections

Section "Dummy Section" SecDummy

; use your own URL and login@pwd. Password hidden from user with /popup "ALIAS"

inetc:😛ut /caption "service pack upload" /popup "" "ftp://takhir:somepwd@localhost/subdir/inetc.dll" "$EXEDIR\inetc.dll"
Pop $0
MessageBox MB_OK "Upload Status: $0"

SectionEnd
Sorry, CLI output is in Russian, but it is not difficult to understand
>dir /S /W
Том в устройстве C имеет метку OS
Содержимое папки C:\Users\takhir\Documents\wftpd\shared
[.] [..] [subdir]
0 файлов 0 байт
Содержимое папки C:\Users\takhir\Documents\wftpd\shared\subdir
[.] [..] inetc.dll
1 файлов 20_480 байт
Всего файлов:
1 файлов 20_480 байт
5 папок 130_276_462_592 байт свободно
StephanB86#
It's not working for me. User got the permission to read/edit/create/execute.

inetc:😛ut /caption "service pack upload" /popup "" "ftp://myuser:mypass@192.168.0.150:8021//Application/Test//inetc.dll" "C:\DELL\5mb.bin"
Pop $0
MessageBox MB_OK "Upload Status: $0"
Returns: Upload Status: Reget Error

*For testing I created a 5mb.bin*

With CLI and ftp open it's possible. Also tried several attempts using extra slashes.
skuallpa#
Hello,

I have a problem with the unicode build of inetc. I am trying to send post values to a script on my website.

This is my command line:

inetc:😛ost "t=i&v=2" /SILENT /TIMEOUT 2500 "https://www.mywebsite.com/myscript.php"  "$TEMP\BD-827364682984.txt" /END
Bot nothing is send, as if the connexion could not be established.

Thanks in advance for your help
Takhir#
I see one bug in code for UNICODE - POST message size should be defined in bytes, not in characters. But probably content-type header should be also changed to
Content-Type: text/html; charset=utf-16
Or this should be 16LE ?
BTW does ANSI version works with your request?
Takhir#
Idea to send Unicode string in http body is very attractive, but my experiments with Unicode POSTs were dissapointing. An it looks like browser sends form data as multibyte even if form was downloaded in page with utf encoding. So I just added body string convertion to multibyte, this worked in my tests. Please test attached dll.
skuallpa#
Hello Takhir,

I have just tested the dll that you have attached and all work well. The problem is corrected (post values are sent correctly)

Thanks a lot for your work!

Regards
robod#
Zdravstvuj Takhir :-),

I'm wondering if you could help me with this.

I've got a php script which allows me to upload a file (just a normal HTML form with upload). I'd like to post data to that script and upload a file.

So, the question is - is it possible to use inetc:😛ost to upload a file?
I guess I can use the TEXT2POST field, but I would have to MIME encode the file as a text and I'm worried that it will not be long enough.

If it's not possible, have you (or anyone else) got a better idea how to do it? Alternatively, would you be able to enhance inetc, so it's possible?

I can't use put as it's a IIS server and I can't enable webdav (to allow put).

Thanks,

Rob
Takhir#
I don't have ready solution for this 🙁 Code sample may help, but I am not sure if I'll can find time for big changes in plug-in right now. I found one MS code sample, but it not sends file name to server while for normal (html form) uploads I can easy get file name in php...
SinusPi#
I added the capability of using files as POST data, so as not to be limited by the NSIS variable size.

Usage: /FILE "filename" among inetc:😛ost options. The 'content' parameter still needed, so it amounts to
inetc:😛ost "blah" /FILE "filename" .....

Attached: source file with the modification, and a .dll with it compiled in. Non-Unicode, I somehow couldn't get those settings to compile, but didn't have time to figure it out at all.
Takhir#edited
I like simple solutions 😉
Few minor improvements and testing required, but idea looks good. Inet samples use HttpSendRequestEx() and InternetWriteFile(), but your approach may work as well - need to test this at least on 1MB files. And IMHO some corrections required: POST body size should be file size, not strlen() in this case (jpeg file may have a lot of zeroes); additional error handling for file IO required (part of file may be locked... in theory 🙂 ); first parameter may be used as file name, /FILE option this case will be without parameter. And may be good to think about MIME-encoding of file to be sent, and about content headers like Content-Disposition: form-data; name="ImageData"; filename="somefile.jpg" Content-Type: image/jpeg - this sends file name I wrote above (sample from http://pics.livejournal.com/doc/prot...ata.simple.bml ).
But any case this looks good, thanks for your help, SinusPi!
robod#
Hi there,

Not sure if it helps, but here is how can this be implemented. The example is using python and wget, but shows the necessary steps that are involved in posting a file:

(www.noah.org/wiki/WGET_CGI_Post)

And this is what the post request looks like when uploading a file in FireFox:

Content-Type: multipart/form-data; boundary=---------------------------188752843329869
Content-Length: 76298

-----------------------------188752843329869
Content-Disposition: form-data; name="file"; filename="HttpAnalysisPluginSP14.zip"
Content-Type: application/x-zip-compressed

<The base64 encoded data go here>

-----------------------------188752843329869
Content-Disposition: form-data; name="submit" Submit
-----------------------------188752843329869--
Wizou#
Hello..
I need also to use the POST request with /FILE support (to skip NSIS string limitations)
Where can we get this updated version of inetc?
Is it available yet?

BTW, thanks for the plugin 🙂

Olivier
robbertdam#
Download fails

Hi, great plugin. I use it in my installer to download & install the .NET framework when it is not yet installed. It works perfect 99% of the time.

However, once in a while a customer calls that it does not work. When they retry it does work. I'm not entirely sure but the problems seems to occus when my installer is executed immediately from Firefox. I've tried to reproduce it on a virtual machine, and it occurs exactly one time. After that it keeps working fine.

Is this a known issue? If not, I'm happy to help to debug this issue. Is there a way to get logs or anything?

Thanks,
Robbert Dam
Takhir#
/FILE option now available in inetc. This is not classic file post implementation, but this work and file content is available as http input. File name (tail of TEXT2POST parameter) added to HTTP headers as Filename: header. Samples included into new package. Please test before using 😉.
Also please note new sample on wiki page http://nsis.sourceforge.net/Inetc_plug-in from Edward Marshall & Jonathan Beddoes - how to restore installer window after silent calls from .onGUIInit
punkomat#
Progress bar size

How can I make the download progress bar have the same size with the global installer progress bar ? (I'm using MUI)
Now it's kind of goofy looking:

punkomat#
Thanks, I took your suggestion. If anyone needs this, just modify inetc.rc and rebuild:

IDD_DIALOG3 DIALOG DISCARDABLE  0, 0, 300, 62
STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE
FONT 8, "MS Sans Serif"
BEGIN
CONTROL "Progress1",IDC_PROGRESS1,"msctls_progress32",0x0,0,23,
300,11
CTEXT "",IDC_STATIC1,0,8,266,11
PUSHBUTTON "Cancel",IDCANCEL,213,41,80,16
END
When recompiling with a newer Visual Studio, make sure you link against libcmt.lib and not msvcrt.lib as by default, otherwise you will require msvcrXY.dll at runtime depending on your VS version. The statically linked plugin is a tad larger, but works everywhere.
Animaether#
Probably better if the plugin conformed to the UI at hand.. I'm guessing your adjustments would break its working with a Classic interface (or UMUI, XPUI, etc.) / other font sizes (inherent dialog unit<>pixel changes.. original plugin suffers from this as well).

I used the WndSubClass plugin to handle some of that.. lot more trouble than it's worth, though 😉
Afrow UK#
@punkomat: also make sure you tell VS not to embed a manifest otherwise (I believe) the CRT dependency remains.
@Animaether: that mod should work fine because it's in dialog units not pixels.

Stu