Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Internet (https://www.clubdelphi.com/foros/forumdisplay.php?f=3)
-   -   Descargar fichero desde servidor linux (https://www.clubdelphi.com/foros/showthread.php?t=90255)

rmoraglez 04-05-2016 15:50:54

Descargar fichero desde servidor linux
 
Hola:

Quiero hacer una aplicación, usando Delphi XE5, que permita desde una PC con Windows descargar ficheros ubicados en un servidor linux.
Me gustaría que me orientaran qué componentes puedo usar para implementarlo y si hubiese algún ejemplo de cómo hacerlo, muchísimo mejor.

A la espera de su atención.

Saludos,
Reina

fredo 04-05-2016 15:58:24

esto es para bajar por url, si quieres copiar por la red es mas facil....

Código Delphi [-]
function Download(Url: string; Archivo: string): Boolean;
var
   hFile: THandle;
   hNet: HINTERNET;
   hUrl: HINTERNET;
   Buffer: array[0..102400] of Char;
   BytesRead: DWORD;
   BytesWritten: DWORD;
begin
    Result := FALSE;
    hFile := CreateFile(PChar(Archivo), GENERIC_WRITE, 0, nil, CREATE_ALWAYS,
    FILE_ATTRIBUTE_NORMAL, 0);
    if (hFile <> INVALID_HANDLE_VALUE) then
    begin
         hNet := InternetOpen('agent', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
         if (hNet <> nil) then
         begin
              hUrl := InternetOpenUrl(hNet, PChar(Url), nil, 0,
              INTERNET_FLAG_RELOAD, 0);
              if (hUrl <> nil) then
              begin
                  while (InternetReadFile(hUrl, @Buffer, sizeof(Buffer), BytesRead)) do
                  begin
                      if (BytesRead = 0) then
                      begin
                          Result := TRUE;
                          break;
                      end;
                      if (not WriteFile(hFile, Buffer, BytesRead, BytesWritten, nil))
                      then break;
                      if (BytesRead <> BytesWritten)
                      then break;
                  end;
                  InternetCloseHandle(hUrl);
              end;
              InternetCloseHandle(hNet);
        end;
        CloseHandle(hFile);
    end;
end;

rmoraglez 04-05-2016 16:15:49

Muchas gracias por su pronta respuesta.
Le agradecería si me pudiese mostrar cómo sería por la red, porque creo que usare esa vía de enlace.

Saludos,
Reina

fredo 04-05-2016 16:22:54

Cita:

Empezado por rmoraglez (Mensaje 504938)
Muchas gracias por su pronta respuesta.
Le agradecería si me pudiese mostrar cómo sería por la red, porque creo que usare esa vía de enlace.

Saludos,
Reina

copyfile jajajaj es como se hace normalmente, claro que necesitas tener el servicio de linux para compartir archivos activo y tener el permiso adecuado osea logueado a la maquina....


La franja horaria es GMT +2. Ahora son las 03:12:14.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi