Ver Mensaje Individual
  #1  
Antiguo 21-11-2019
botones67 botones67 is offline
Miembro
 
Registrado: may 2003
Posts: 104
Reputación: 0
botones67 cantidad desconocida en este momento
subir ficheros a dropbox

Hola amigos del foro.
Estoy intentando seguir un ejemplo que encontré para poder subir files a dropbox
Código Delphi [-]
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs,IdHTTP, IdSSLOpenSSL, System.JSON;

type
  TForm1 = class(TForm)
    procedure FormActivate(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
   Function Download(Const Folder, Nam, LocalFile: String): Boolean;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
{ TForm1 }

function TForm1.Download(const Folder, Nam, LocalFile: String): Boolean;
  Var
  FIdHTTP: TIdHTTP;
  file_path,fAccessToken: String;
  StrResp: TmemoryStream;
  json: Tjsonobject;
Begin
  Result := False;
  fAccessToken:='Aqui va mi token de acceso a dropbox';
  If Folder = '' Then
    file_path := Nam
  Else
    file_path := trim(Folder + '/' + Nam);

  FIdHTTP := TIdHTTP.Create;
  StrResp := TmemoryStream.Create;
  json := Tjsonobject.Create;
  Try
    FIdHTTP.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(FIdHTTP);
    FIdHTTP.IOHandler.LargeStream := True;
    FIdHTTP.Request.CustomHeaders.AddValue('Authorization', 'Bearer ' + fAccessToken);
    json.AddPair('path', TJSONString.Create( file_path));
    FIdHTTP.Request.CustomHeaders.AddValue('Dropbox-API-Arg', json.ToString);
    FIdHTTP.Request.Accept := 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
    FIdHTTP.HandleRedirects := true;
    FIdHTTP.Request.ContentType := '';
    Try
      FIdHTTP.get('https://content.dropboxapi.com/2/files/download', StrResp);
    Except
      Result := False;
    End;
    Result := FIdHTTP.ResponseCode = 200;
    StrResp.Position := 0;
    If Result Then
      StrResp.SaveToFile(LocalFile);
  Finally
    FIdHTTP.Free;
    StrResp.Free;
    json.Free;
  End;
End;

procedure TForm1.FormActivate(Sender: TObject);
begin
 Download('/Aplicaciones', 'mail.ini', 'c:\mail.ini');
end;

end.
no puede cargar ssl library.

Según embarcadero hay que instalar libeay32.dll y ssleay32.dll librerias.
http://docwiki.embarcadero.com/RADStudio/Rio/en/OpenSSL pero el error persiste, ¿ alguien puede saber que ocurre?.

Un saludo para todos.
Imágenes Adjuntas
Tipo de Archivo: jpg error2.jpg (29,9 KB, 6 visitas)
Responder Con Cita