Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Photo Upload App - Robust, when no net available

Options
  • 16-12-2013 9:24pm
    #1
    Registered Users Posts: 669 ✭✭✭


    Hi,

    I'm just starting to look into an app that will allow users (not public, invited to app via a link) to take a photo, add some text information into some extra fields, and then upload the photo and text to a server. The users will not require to be able to view the photos afterwards, nor are they particularly time sensitive, the server can receive the photos up to maybe 72 hours after they are taken.

    However, the locations that will be photographed may or may not have good internet coverage, so the photos might remain on the device until the user returns to the office or wifi coverage.

    I don't really want the users to have to open the app just to ensure that the photos get uploaded, I'd like this to be handled in the background.

    I've broadly thought of 3 ways to do this:

    1. Store the data in the local sql-lite and set a flag "Not yet Uploaded", then have something running that checks for entries, say every hour, and attempts to upload. Not a great solution to be honest.

    2. Dropbox has a "sync API" that allows you to leave the data in the background, and it will manage the upload once connectivity is available. This may however, have problems if the user already has a dropbox account on the phone. It will upload to a dropbox folder, but I don't think I can set a "fixed" folder that won't interfere with the users own dropbox account details.

    3. The native email app on a phone is fairly robust, as in it will allow an email to be composed offline and it will sit in the outbox until there is connectivity. I could use the app to place an outbound email in the outbox with the photo attached and let the email app look after transmission.

    Finally, the whole thing will be done in phonegap, I have it set up with the required menus, forms and it currently takes the photo, but only stores it locally on the phone.

    Any suggestions?


Comments

  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    You spend too much time considering different approaches to uploading, when in reality describing what the app is would have been far more useful.

    So, this is an app, which allows one to take a photo, add some - effectively - text data (user comments, GPS coordinates, and so on) to be associated to the photo and then uploaded (as a background process) to your server application, which will receive and process the photo and associated text data.

    If so, and focusing on the uploading, then this is all quite possible to develop; indeed, you mentioned the phone's email client - what do you think it does when you press send on an email with an attachment?

    Essentially, you want to open up a socket to your server and send your photo and other data (either separately or together - depends on what protocol you use), over TCP/IP and as a separate background thread, which then reports when it has completed the upload and (for bonus points) receives confirmation on a checksum from the server.

    However, before you can do this, you need a background process that checks your internet reception; either as a process that runs to check every ten minutes or ideally as a listener that is triggered by a connection change event.

    As such, I'd concentrate on three areas of development; asynchronous background threads/tasks, connection listeners and socket programming. These should give you the necessary tools to build your upload process (although, you still have to have something on the server to catch it for you).

    Only thing that I'd be concerned about is whether it's going to be very robust or even usable done using PhoneGap.


  • Registered Users Posts: 669 ✭✭✭Patrickof


    Unfortunately I'm prohibited from saying what exactly is being photographed for now, it's nothing improper though I can assure you. Also, a lot of the photos will be taken in areas where theres little or no connectivity for data on the phone.

    I was hoping to be able to avoid "reinventing the wheel" as such, by that I mean can I avoid having to develop my own background process, socket/ event handlers and use the existing facilities on the phone.

    A lot of the users (I don't anticipate more than 400 in total) will be new to smartphones (some will even be trading up from a Nokia 6310i to use this!!) so I want it to be as simple as possible.

    Literally, open the app, it'll prompt you and show you exactly how to take the photograph (there's an element of measurement in this), add a few relevant text fields, grab the GPS coords and they then hit "Submit".

    What I want to avoid is having a need for them to keep a queue of photos that they need to monitor have been transmitted to the server.

    If I have the app create an email, to a specific address, add the text data, attach the photo and then pop it into the default mail app on the phone. The mail app would then handle all the connectivity issues, checking for net availability and sending the file whenever it can.

    I already have a php script at the server that can monitor an email address, extract an attachment and drop it all into a mySQL database (sugarcrm). I can let sugarcrm handle sending back receipt confirmations etc.

    Essentially, I don't want to be in a situation where the user discovers 3 weeks after taking the photo that its still sitting on his phone, not having been transmitted.


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Patrickof wrote: »
    I was hoping to be able to avoid "reinventing the wheel" as such, by that I mean can I avoid having to develop my own background process, socket/ event handlers and use the existing facilities on the phone.
    Taken to its conclusion, you don't need any app at all; just direct your users to take photos, and send them, via email, with whatever comments are also required by your server application - you can handle security at the server, white-listing only those email addresses of those invited. No need to invent or reinvent anything.

    It really comes down to what you want; coding any application will require some level of 'reinventing the wheel' - that's why code reuse is such a fundamental topic in programming strategies. So, is it something quick and dirty that works, or something professional that people would be willing to pay for?
    What I want to avoid is having a need for them to keep a queue of photos that they need to monitor have been transmitted to the server.
    Problem with using third party apps there is also that you have to accept how they deal with failed transmissions. For example, with email clients, some will try to resend once, some will try to resend only a finite number of times, others not at all. And then what? You've a failed email sitting in the client outbox indefinitely.
    If I have the app create an email, to a specific address, add the text data, attach the photo and then pop it into the default mail app on the phone. The mail app would then handle all the connectivity issues, checking for net availability and sending the file whenever it can.
    Actually, you'd have an app which 'shares' or 'sends via' another app - in this case the email client. User interaction will be required, even if you initiate the process, and the email client will end up launching to do all of this. It's not seamless.
    I already have a php script at the server that can monitor an email address, extract an attachment and drop it all into a mySQL database (sugarcrm). I can let sugarcrm handle sending back receipt confirmations etc.
    If bandwidth or connectivity is an issue for you, then I'd advise against using SMTP (email), as the way binary attachments are encoded in emails is not very bandwidth efficient (it bloats them by about 50%, AFAIR).
    Essentially, I don't want to be in a situation where the user discovers 3 weeks after taking the photo that its still sitting on his phone, not having been transmitted.
    Off the top of my head, the only way to be sure is to reinvent the wheel and handle this process from beginning to end. Where it comes to connectivity, the connection listener API for PhoneGap, I linked to above, looks pretty straight forward, TBH.


  • Closed Accounts Posts: 6,925 ✭✭✭RainyDay


    Would an auto-upload feature for any of the main photo sharing sites work for you? I use flickr-folio to automatically upload photos to Flickr. The only drawback with this for me, is that it requires the phone to be plugged in to charge for the upload to take place via wifi, which isn't ideal. There is an option to upload over the data connection straight away.


Advertisement