Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Internet
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 11-02-2013
Xavierator Xavierator is offline
Miembro
 
Registrado: nov 2003
Posts: 31
Poder: 0
Xavierator Va por buen camino
SFTP para Delphi 7 ?

Hola, alguien conoce algun componente o funcion para bajar/subir archivos por SFTP ?

he encontrado esta funcion, pero solo es para FTP: http://www.swissdelphicenter.ch/torr...de.php?id=1095

hay otros componentes, pero son para versiones superiores de Delphi 7

Gracias, Xavi
Responder Con Cita
  #2  
Antiguo 11-02-2013
WkaymQ48 WkaymQ48 is offline
Miembro
NULL
 
Registrado: jul 2012
Posts: 43
Poder: 0
WkaymQ48 Va por buen camino
Puedes usar Curl, mas concretamente la librería libcurl.

Aquí tienes un ejemplo:
http://www.delphiaccess.com/forum/ge...un-ditio-sftp/

Soporta ftps y sftp solamente tendras que indicar el protocolo correspondiente en la url.

Saludos
Responder Con Cita
  #3  
Antiguo 11-02-2013
Avatar de movorack
[movorack] movorack is offline
Miguel A. Valero
 
Registrado: feb 2007
Ubicación: Bogotá - Colombia
Posts: 1.346
Poder: 20
movorack Va camino a la famamovorack Va camino a la fama
Hola,

Leyendo un poco al respecto, me informo que los componentes indy no manejan SFTP.

en DelphiAccess encontré la siguiente respuesta donde usan CURL para transferir archivos vía SFTP.

Cita:
Empezado por Seoane
Código Delphi [-]
function ReadFromStream(Buffer: PAnsiChar; Size, Count: Integer;
  Stream: TStream): Integer; cdecl;
begin
  Result:= Stream.Read(Buffer^,Size*Count) div Size;
end;
 
function SaveToStream(Buffer: PAnsiChar; Size, Count: Integer;
  Stream: TStream): Integer; cdecl;
begin
  Result:= Stream.Write(Buffer^,Size*Count) div Size;
end;
 
function Subir(Usuario, Clave, URL, Archivo: AnsiString): Boolean;
var
  Curl: TCURL;
  Stream: TFileStream;
begin
  Result:= FALSE;
  Curl:= curl_easy_init;
  if Curl <> nil then
  try
    // Indicamos que muestre mensajes de todo lo que va haciendo
    if curl_easy_setopt(Curl, CURLOPT_VERBOSE, TRUE) <> CURLE_OK then
      Exit;
    // Le decimos que uses SSL
    if curl_easy_setopt(Curl, CURLOPT_USE_SSL, CURLUSESSL_ALL) <> CURLE_OK then
      Exit;
    // No verificamos la identidad del servidor, suponemos que es quien dice ser.
    if curl_easy_setopt(Curl, CURLOPT_SSL_VERIFYPEER, FALSE) <> CURLE_OK then
      Exit;
    // Indicamos el usuario
    if curl_easy_setopt(Curl, CURLOPT_USERNAME, PAnsiChar(Usuario)) <> CURLE_OK then
      Exit;
    // El password
    if curl_easy_setopt(Curl, CURLOPT_PASSWORD, PAnsiChar(Clave)) <> CURLE_OK then
      Exit;
    // La URL del tipo: sftp://servidor/rutadelfichero
    if curl_easy_setopt(Curl, CURLOPT_URL, PAnsiChar(URL)) <> CURLE_OK then
      Exit;
    // Le indicamos que funcion debe usar para leer el stream
    if curl_easy_setopt(Curl, CURLOPT_READFUNCTION, @ReadFromStream) <> CURLE_OK then
      Exit;
    // Creamos un stream a partir de un archivo
    Stream:= TFileStream.Create(Archivo,fmOpenRead);
    try
      // Aqui le indicamos el stream que debe subir
      if curl_easy_setopt(Curl, CURLOPT_INFILE, Stream) <> CURLE_OK then
        Exit;
      // Aqui le indicamos que la operacion es de subida
      if curl_easy_setopt(Curl, CURLOPT_UPLOAD, TRUE) <> CURLE_OK then
        Exit;
      // Ejecutamos el comando
      Result:= curl_easy_perform(Curl) = CURLE_OK;
    finally
      Stream.Free;
    end;
  finally
    curl_easy_cleanup(Curl);
  end;
end;
 
// Sube el archivo "C;\ART.DAT" al servidor con el nombre "2.txt"
  Subir('test','test','sftp://169.254.0.2:999/2.txt','C:\ART.DAT');
__________________
Buena caza y buen remar... http://mivaler.blogspot.com
Responder Con Cita
  #4  
Antiguo 11-02-2013
Avatar de movorack
[movorack] movorack is offline
Miguel A. Valero
 
Registrado: feb 2007
Ubicación: Bogotá - Colombia
Posts: 1.346
Poder: 20
movorack Va camino a la famamovorack Va camino a la fama
Mira que me picó el bichito de la curiosidad con este tema y encontré un proyecto en BitBucket llamado Libssh2.

Necesitarás mercurial para obtener el código.

Yo lo estuve revisando un poco aunque no te puedo confirmar si compila en Delphi 7
__________________
Buena caza y buen remar... http://mivaler.blogspot.com
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
FTP para subir archivos al servidor en DELPHI y me sirva para lazarus = koiji Delphi para la web 2 05-02-2013 15:52:06
Cliente SFTP chinchan C++ Builder 1 12-04-2012 04:28:12
Crear Cliente SFTP o SSH con delphi JuanchoArg Varios 7 10-03-2011 13:35:27
CodeGear realiza encuesta para Delphi 2008 para introducir nuevas características Black_Ocean Noticias 2 03-04-2008 08:20:03
Hacer FTP seguro SFTP! JuanErasmo Internet 0 02-08-2007 03:48:49


La franja horaria es GMT +2. Ahora son las 04:45:16.


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
Copyright 1996-2007 Club Delphi