Have you ever seen an app that lets you transfer file easily from Mac or any Desktop to your phone with the following features:
No Internet access for file transfer(This is required..Ughh)
- Fast speeds up to 160Mbps (20MBps)
- Easy & Convenient
That’s way too much simple to say I guess. Is it?
But for me, it was nothing more than making it a possible solution as a developer. Remember – We developers could build anything and everything. There is no exception to us, though it takes time & requires your hope.
Beginning of the cause.
I am sitting right down the table, typically trying to study during for my exam. I don’t write lecture notes & hence there came a need to take the photostats of other students notes and then transfer to my MacBook to read them.
Now that was the time… Damn, I am in my hostel, I have only one app installed on my laptop called ‘Android File Transfer’, which sucks all in one. It’s very difficult to navigate within the folders, crashes in between transferring and for god sake, I don’t even remember the location of the files to start transferring.
I could have used any other apps like Xender or Shareit. But that would take me hours to connect to its newly created WiFi hotspot with gibberish names and ultra complex passwords. Then, I thought of Portal app, which was really fast in transferring and connecting was as simple as scanning a barcode.
But.. that too gave up the hope on me, since it did not work on a mobile hotspot it was sending files to. I required a 3rd WiFi network for the transferring to take place.
Also, What if I had to transfer files back and forth across phone and laptop? That’s whole new craziness.
It was time I created my new app – Filexa.
Getting Ideas & Features for the app
Whatever be the file, be whichever phone it’s tested on, I had to bring out the best results.
So instead of just starting completely from blank, I designed a test model like this and asked you people on twitter about the features you would be looking into a file transferring app.
OMG! You guys responses were amazing. I have listed all of them below and… started to think of myself which of ’em all is possible to implement.
Features – End Goal
- Single/multi-thread transfer toggle
- Dark mode UI
- 2.5/5GHz toggle option (currently its API is restricted on Android ?)
- Transfer history
- One click/ Auto sync of selected files/folders
- Transfer pause/resume
- External SD card write access
- Establish Auto ON/OFF connection
- Browsing mobile files on the web to download
- External file upload & link sharing
I too had the similar things in my mind while thinking of this simple interface app. One thing for us developers that certainly needs be addressed in public is error handling for our app.
I always make the joke out of Java, saying half of the code you write in Java is always error handling.Sreekant Shenoy 2019 🙂
But this time, I have tried my best to include Kotlin into the project. As you know, Kotilin works in the least amount of codes compared to Java and the ultimate benefit is that Kotlin can automatically handle with the null pointer exception.
- NodeJS + WebSocket + Express + Socket.IO
- HTML + CSS (Bootstrap) + JS (Dropzone, socket IO)
- Android App (Java, Kotlin + XML + Socket.IO)
I started my Journey.
Before starting any project, designing the website UI & researching into colors accents is usually what I normally do.
This time, I wasn’t confident enough whether I would be able to complete my project, especially because I wasn’t convinced this file transfer would take place from just an XMLHttpRequest, that too without the external server intervening.
So, I made a quick basic website using bootstrap frameworks. Later found out that, It’s relatively simple. I just had to get the local IP address of my mobile phone to the web somehow and send the XHR request.
This request contained the files & its info, with respective headers that when sent as streams to the mobile app parses the input stream to a normal file & stores on the device.
That’s the whole concept behind this.
To let each other – the sender and receiver know the IP address to establish the connection, I had to build up WebSocket.
SocketIO pretty much eases your whole thing and its fun.
What’s WebSocket & Why?
To those who aren’t aware of web-sockets, they are basically a fully connected system just like what your web messaging services like Facebook messenger.
Normally an HTTP request just requests for a URL like www.google.com and serves the response. After getting the response, the connection is immediately cut. This is not the case for web socket!
WebSockets keep the connection alive as long as required for communication.