Downloand from dropbox lazarus / 43-Android ---------------------------------------------------------------------- magleft · 2022-05-16 10:30 Hello. I would like to create a small application that download and upload a file to dropbox. Through windows this was done relatively easily through THTTPSend. There is of course the key issue which gives dropbox, but I think I will be able to solve it. When I tried to do it through android using the jHttpClient class, when I run it in in the emulator during downloand does not output any error message, but does not download the file In upload issues the code 201 but does not upload the file .. When I try to run it on an android device the application closes. I tried with jDownloadManager1 but could not see where the headings are defined. I tried with the THTTPSend class but both in the download and in the upload it returns the code 500. Does anyone have any idea how the problem could be solved? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TAndroidModule1.jButton3Click(Sender: TObject); // downloand fileconst  file_source='"/myfolder/myfile.jpg"';   downloandfile='newfile.jpg';var  http: THTTPSend;  Url: string;  jpath:String;begin  http := THTTPSend.Create;  http.Headers.Add ('Authorization:'+atoken) ;  //Authorization  http.Headers.Add ('Dropbox-API-Arg:'+'{"path":'+file_source+'}') ;  Url := aurldown;  jpath :=self.GetEnvironmentDirectoryPath(dirDownloads)+'/'+downloandfile  ;  if http.HTTPMethod('GET', Url) then  begin     HTTP.Document.SaveToFile(afile)  ;  end  else    begin      ShowMessage('error(' + IntToStr(http.ResultCode) + ')' + http.ResultString);    end;  http.Free;  SHOWMESSAGE('fINISH');end; //---------------------- procedure TAndroidModule1.jButton4Click(Sender: TObject); //uploand fileconst  alocalfile='myfile.jpg';  file_source='"/myfolder/myfile.jpg"';var  http: THTTPSend;  Url: string;//  data:TfileStream ;  data:TStringList   ;  jpath:String;begin  jpath:=alocalfile;      http := THTTPSend.Create;  data:=TStringList .Create();  data.LoadFromFile(jPath);  HTTP.MimeType := 'Application/octet- stream';  http.UserAgent :='api-explorer-client';   HTTP.Headers.Add('Authorization' +':'+atoken) ;  http.Headers.Add('Dropbox-API-Arg'+':'+' {"path":'+file_source,"mode": {".tag":"overwrite"},"autorename":false,"mute":false,"strict_conflict" :false}') ;  Url := 'https://content.dropboxapi.com/2/files/upload/'  ;  try    HTTP.Document.LoadFromFile(jpath);    if HTTP.HTTPMethod('POST', URL) then       jPanel1 .Text :='Ολοκληρώθηκε η αποστολή του αρχείου'       else jPanel1 .Text :='Σφάλμα!!! Δεν έγινε η αποστολή του αρχείου....';       SHOWMESSAGE(INTTOSTR(HTTP.ResultCode)+':'+HTTP.ResultString);  finally    begin    jPanel1  .Text :=http.ResultString+http.Headers.Text ;    HTTP.Free;    end;    end;  data.Free ;  SHOWMESSAGE('OK');end;//------------ android   procedure TAndroidModule1.jButton1Click(Sender: TObject);const  alocalfile='myfile.jpg';  file_source='"/myfolder/myfile.jpg"';var  Url: string;begin  jHttpClient1.AddClientHeader('User-Agent','api- explorer-client') ;  jHttpClient1.AddClientHeader('Authorization:',atoken) ;  //Authorization  jHttpClient1.AddClientHeader('Dropbox-API- Arg:','{"path":'+file_source+'}') ;  jHttpClient1.UploadFormName:='DropBox' ;  Url := aurldown;  jHttpClient1.GetAsync (url) ;  SHOWMESSAGE('wait...');end; procedure TAndroidModule1.jHttpClient1ContentResult(Sender: TObject;  content: RawByteString);var  list: TStringList;  jpath:String;begin  showmessage('downloanding');  jpath:=Self.GetEnvironmentDirectoryPath(dirDownloads)+'/'+alocalfile;   if FileExists(jpath) then      DeleteFile(jpath) ;  list:= TStringList.Create;  list.Text:= content;  list.SaveToFile(jpath);  list.Free;   if FileExists(jpath) then      showmessage('file exist')   else       showmessage('Not Exist');end;  procedure TAndroidModule1.jButton2Click(Sender: TObject);const  alocalfile='myfile.jpg';  file_source='"/myfolder/myfile.jpg"';var  Url: string;  ms:TMemoryStream ;  jpath:String;begin  showmessage('uploanding');  jpath:=Self.GetEnvironmentDirectoryPath(dirDownloads)+'/'+alocalfile;  jHttpClient1.AddClientHeader('MimeType:','Application/octet-stream') ;  jHttpClient1.AddClientHeader('UserAgent:','api-explorer-client') ;  jHttpClient1.AddClientHeader('Authorization:',atoken) ;  jHttpClient1.AddClientHeader('Dropbox-API-Arg:',' {"path":"'+file_sour ce+'","mode":{".tag":"overwrite"},"autorename":false,"mute":false,"str ict_conflict":false}');  Url :='https://content.dropboxapi.com/2/files/upload/';  jHttpClient1.UploadFile(url,jpath) ;//  jHttpClient1.Post(aurldown);   showmessage(inttostr(jHttpClient1.GetResponseCode))  ;  showmessage('ok');end;  procedure TAndroidModule1.jHttpClient1UploadFinished(Sender: TObject;  connectionStatusCode: integer; responseMessage: string; fileName: string);begin  showmessage('finish upload connectionStatusCode' + inttostr(connectionStatusCode));  showmessage('finish upload responseMessage'+responseMessage);end;