Recent

Author Topic: Android and sftp download storage (SOLVED)  (Read 1326 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Android and sftp download storage (SOLVED)
« on: April 11, 2023, 09:49:22 pm »
Hi, someone explains which code to use to not have problems in downloading an SFTP file in the local one? Let me explain better, I use the following code

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModuleSync.AndroidModuleSyncRequestPermissionResult(
  2.   Sender: TObject; requestCode: integer; manifestPermission: string;
  3.   grantResult: TManifestPermissionResult);
  4. begin
  5.      case requestCode of
  6.      1198:begin
  7.             if manifestPermission = 'android.permission.WRITE_EXTERNAL_STORAGE' then
  8.             begin
  9.                 if grantResult = PERMISSION_GRANTED  then
  10.                    ShowMessage('Sucess... PERMISSION_GRANTED !!!')
  11.                 else
  12.                    ShowMessage('Error... [PERMISSION_DENIED] download/upload ok....');
  13.             end;
  14.           end;
  15.      end;
  16. end;    

and

Code: Pascal  [Select][+][-]
  1.  
  2.           if IsRuntimePermissionGranted('android.permission.WRITE_EXTERNAL_STORAGE') then
  3.           begin
  4.  
  5.                SFTPClient1.Download('/root/mydir/input.zip', Self.GetEnvironmentDirectoryPath(DirDownloads) + System.DirectorySeparator + 'input.zip')
  6.           end
  7.           else Log('ERRORE... [PERMISSION_DENIED] il download del file non è consentito ...');
  8.  
  9.  
  10.  

But it never works on the old devices with Android 10. It always tells me that I don't have the permits, even if I have set them. Other ways to download the file?
« Last Edit: April 23, 2023, 12:23:52 am by xinyiman »
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

jmpessoa

  • Hero Member
  • *****
  • Posts: 2328
Re: Android and sftp download storage
« Reply #1 on: April 11, 2023, 11:16:06 pm »
Quote
/root/mydir/input.zip

What ???
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Android and sftp download storage
« Reply #2 on: April 12, 2023, 08:30:54 am »
It is the path to the file on the sftp server
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

MarkMLl

  • Hero Member
  • *****
  • Posts: 8394
Re: Android and sftp download storage
« Reply #3 on: April 12, 2023, 10:02:59 am »
It is the path to the file on the sftp server

What makes you think that the sftp daemon is being run by root on the server? These days that would be most unusual, particularly on a unix server, and most particularly for something with as little security as tftp.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Android and sftp download storage
« Reply #4 on: April 12, 2023, 10:16:04 am »
The path is correct. Don't worry, because I see the file. The problem is related to saving to local storage. It always tells me that I don't have the permissions, even though I have them activated.
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

jmpessoa

  • Hero Member
  • *****
  • Posts: 2328
Re: Android and sftp download storage
« Reply #5 on: April 12, 2023, 08:47:54 pm »
With each new version android is making it difficult to access directories outside the scope of the application....  for Android >= 10 you can try this demo:

  "AppPublicFoldersAccessDemo1"
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Android and sftp download storage
« Reply #6 on: April 16, 2023, 10:53:25 am »
But I'm also fine with saving the zip in a directories inside the scope of the application. How can I do? My goal is to download a zip file that has excel files inside to read. Once read I can delete them.
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

Mongkey

  • Sr. Member
  • ****
  • Posts: 439
Re: Android and sftp download storage
« Reply #7 on: April 21, 2023, 05:44:24 am »
you need to unzip it, read what contain inside. May be zip GUI sample project your best companion for this.

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: Android and sftp download storage
« Reply #8 on: April 23, 2023, 12:23:38 am »
you need to unzip it, read what contain inside. May be zip GUI sample project your best companion for this.
Thank you very much. I solved.
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

 

TinyPortal © 2005-2018