What is the best way to retrieve data from a server

Hello, I am new to App development, so I am looking for some advice. I want to develop an app for iPhone, which downloads files (pdf, jpg)from a server to the local storage. I also want to get data from the server to be used in my app. This could be a database access or just simple xml files. I want a secure access based on userid and password. Since in a later version, my app should also run on Android Phones, I am reluctant to use iCloud. I was thinking sftp, but that does not seem to be supported for iOS.

Answered by DTS Engineer in 855063022

Sorry I didn’t reply sooner; I wasn’t notified of your update. However, it seems that Hoffman did a good job of covering the issues here (-:

At this point I think you need to talk to the folks who run your web server. There’s a three-way Balance of Pain™ to be struck here:

  • They can support HTTPS uploads, which will make your life significantly easier.
  • Or not, in which case you’ll have to write or acquire a library that implements SFTP.
  • And that might cause problems for some users, those running on networks that only support HTTP networking.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

The best approach depends on your server infrastructure. Is that something you intend to manage yourself? Or are you trying to work with an existing server?

I was thinking sftp

That only makes sense is very limited circumstances. For maximum compatibility I recommend that you use HTTPS. However, that’s not always the right choice, and hence my question above.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I want to use an existing server, which I do not manage myself. We do have a Webserver from IONOS which is used to display webpages. I want to store files on that server. I do have an ID so I can access these files via SFTP and an ssh session. But that might not be the best option. I am open for suggestions

There is no one "best" way.

Lots of details here not in evidence, too.

Transfers using https via TCP 443 are the most compatible means for transferring files around, and is the means least likely to encounter a firewall, as Quinn sagely suggests. This allows you to access and download a data file on whatever web server you are using.

sftp is absolutely possible too, but that usage can encounter outbound network firewalls and policy-related blocks on TCP 22 traffic (or on other ports, or on all but specific ports).

Also, any client-side private key or password usage is necessarily and absolutely always assumed to be compromised.

Embedded sftp credentials are not secret.

Whatever you decide to use for the data transfer, there are various ways to transfer files and blobs of data around, and (outside of a web browser and related tech) one of the more ubiquitous choices for the transfer is curl and libcurl. curl can transfer data using most common protocols.

You might also want to provide a pointer for locating your file or data blob too, whether that is via a HTTP redirect, or some data returned from your website, or via a DNS translation (such as a DNS SRV service record or such) or some other indirect means, so that you don't end up stuck between needing to move the file for whatever reason (storage, load, uptime, new hosting provider or CDN, whatever) and having to push out an app update to allow that. This pointer also for avoiding support calls from those that haven't updated the app.

You may also want to embed file format version information somewhere too, so that an old app can react appropriately and display an appropriate diagnostic message upon meeting a new file version.

Version skew is a thing. Think about how you can implement your app and file upgrades.

Sorry I didn’t reply sooner; I wasn’t notified of your update. However, it seems that Hoffman did a good job of covering the issues here (-:

At this point I think you need to talk to the folks who run your web server. There’s a three-way Balance of Pain™ to be struck here:

  • They can support HTTPS uploads, which will make your life significantly easier.
  • Or not, in which case you’ll have to write or acquire a library that implements SFTP.
  • And that might cause problems for some users, those running on networks that only support HTTP networking.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

What is the best way to retrieve data from a server
 
 
Q