Apache scripts for Android app development
These pages will instruct how to combine Apache scripting with Android app development. However, you're not limited to Android app development here at all. Apache web server may be used from any browser and from any device. Whether you're developing a cloud image hosting, an online image manipulation service or any image related app, service or storage, these examples may prove useful. These may be used from any app - be it iPhone, Android etc but from normal web browsers as well!
Mobile phones have relatively short lifetimes. They will break down, get lost or otherwise wear out. Network services are made to back up precious items such as pictures, important files and so on. Similarly, your app could benefit from the backup services. Another aspect is online file manipulation. Complex image handling may be done in the network making it useful for all the mobile phones, tablets and laptops.
Apache itself is a web server software. It may be configured in a hundreds of ways to serve the particular goals. Root access is generally required to configure it. However, it can run Linux shell scripts. This is what we're targeting here. There are a number of other web servers that could do the same task but we'll use the Apache as it's quite popular.
Why not PHP, perl or python?
Python suffers from incompatibilities between versions. Although this may be true in Windows environments, it's not necessarily such a pain in Linux distros. All scripting languages are some kind of translators, some being more heavier than the others. What we do doesn't require an endless number of libraries and API:s to be learned. I personally think Linux shell scripts can do pretty much all that's required. So why bother with the more complex translators? If performance is required then C/C++ may be used to perform the tasks.
Configuring Apache for shell scripts
The second example contains information how to set up the Apache server from scratch. Yet, the details how to run Linux shell scripts is also introduced. Usually you need the root access to perform these steps.
Sending images to the cloud storage
This example illustrates how to upload files to a remote server. The remote server uses a shell script to store the data accordingly. Some upload / download speed optimization techniques are represented as well. We've tried larger than 100 Megabytes transfers successfully.
Serving images via Apache server
Apache image sharing script shows how an arbitrary image may be shown on a browser or even on your Android app. It may be useful for ads, self-updating themes, random images, cloud storage preview or whatever the purpose. A heavy amount of images stored locally isn't always a good idea. Once the device breaks down, it's often hard to recover them.
Our focus is in Apache web server scripting. URLs may be constructed in such a manner than eventually the Apache server calls the scripts with parameters passed in the URL itself. There are no limits on what may be done next.
Cloud storage example
A cloud storage will have all user images uploaded. However, previewing them is not efficient if all images need to be downloaded from the server every time. This might take a huge amount of bandwidth and time! Instead, a preview version that has compressed and perhaps resized the original image could be used to speed up your Android app. We propose a way to handle this situation with server-side image manipulation.
Shell script based image cache
Already manipulated images may be worth storing permanently for a certain duration. Usually the operation to do advanced image operations will cost you a lot more than storing them for a few days. Our image cache sample provides a way to construct a cache for this purpose.
reCAPTCHA with Linux shell script
reCAPTCHA is a great way of filtering the endless number of bots on the Internet to spam your commenting sections. It's Google's way of checking out whether your a bot or not. We'd recommend it instead of building those outdated "enter the letters" from an image. Our sample shell script does this all for you!
Written on April 2018 by Eero Nurkkala