37
Views
5
Comments
Best practice to handle binary data in mobile offline mode
Application Type
Mobile

Hello.


I have an existing mobile application that was not initially built with offline capabilities in mind. However, now I have a request to make it work offline (more like when the signal strength is poor). In short, the app is used to take photos under a specific concept (such as a department), the users can view them, take more photos, delete photos, and later in the business flow, send them all (or the ones they select) by email to a designated recipient.


I've been investigating and reading the documentation to understand the best approach and best practices for implementing such a scenario. While doing so, I came across this presentation from the OutSystems Worldwide Developer Conference 2018. In the Q&A at the end of the session (around 56:13), there was a question about the best practice in storing a large set of images. In the answer given, the presenter recommends saving a thumbnail in the local storage and the original image in the device's file system using the File Transfer Plugin. Then, to show the photos to the users, they show the thumbnail, and if the user clicks on it, they get the original image. He also mentions that at that time, they didn't have any example of this implementation, but that there was another presentation with that example. 


I have some questions:

  1. Is this still the recommended approach and best practice for such a use case?
  2. Does anyone have an example of this implementation, or where I can find it?
  3. How should we manage the synchronization of photos from and to the server? I was thinking of trying to sync each photo to the server as soon as it is taken, right after storing it in the local storage, but I'm not sure if this is the right approach. What if it fails?
  4. When a user navigates to the details of a department, is it smart to trigger the offline data sync only for that department, using the appropriate SyncUnit together with a department identifier or something like that? 


Thanks in advance for any help and suggestions you may have.


Best regards,

André

2023-12-26 10-35-28
OutSystems Neo
Staff
Hello André,

The integration of offline capabilities into your mobile application will involve numerous practices and plugins. However, addressing your specific questions:

1. Storing the images: The approach you pointed out, which is saving a thumbnail in the local storage and the original image in the device's file system using the File Transfer Plugin, is still relevant and generally recommended. When bandwidth and device storage are challenges, this approach strikes a reasonable trade-off.

2. Example Implementation: Unfortunately, I do not have a specific example to point out for this exact use case. However, you may look into the OutSystems Forge for relevant components or patterns. The Mobile Patterns UI]
2016-04-22 00-29-45
Nuno Reis
 
MVP

Hello.

Why you want to make it by department? Is it volume? i would do it for everything.


Regarding your approach: That is very valid.

I'd say that is a "mostly offline" take on the problem. Ideal for the worst scenario.

If it only happens once in a while, or for short time (you are doing inventory and go to the basement for 30 minutes) your perspective could be:

  • Always save locally;
  • Every time you are online try to sync the oldest first;
  • Remove the local copy as soon as the server confirms reception;
  • Maybe keep some counter to alert the user they are close to some limit (number of photos, time without syncing, megabytes, etc).



2018-11-07 02-41-33
André Dinis

Hello.

Just to clarify, I referred to it as a "department" purely for the sake of the example. The actual grouping of the photos is based on a different concept, which isn't relevant to go into detail about here. 

I'm considering doing it by department because, when navigating to a department’s details, I want the associated photos to load as quickly as possible. I assume that triggering a sync for all departments would take longer and delay access to the relevant data. 


Regarding my approach, you're right, I’m planning for the worst-case scenario. In practice, this actually happens fairly often, even if only for short periods.

I have a few questions and remarks regarding your suggestions: 

  • I definitely plan to always save the photos locally;
  • Just to clarify, you're suggesting triggering a sync using the SyncOnOnline event/configuration, correct?
    I think the challenge with that approach is that, in most cases, the devices aren't fully offline, they typically have a very weak or unstable connection. 
  • Why do you recommend removing the local copy as soon as the server confirms reception? Wouldn’t that require a sort of hybrid approach where I have to list photos both from local storage and from the server? 
    My idea is to always display photos from local storage. I understand they can’t stay there forever, so I was considering removing them after a certain period (e.g., one week to one month). That seems acceptable for the use case, as users typically won’t revisit a department after that period. 
  • I'm not sure if I understood your last suggestion.


Thank you for the suggestions and the discussion so far.

2016-04-22 00-29-45
Nuno Reis
 
MVP

Yes, it would be SyncOnOnline. One photo at the time, chronologically.

I was assuming you wanted to send the photos. If you need them locally and network is poor, you should keep them.

My suggestion is so that users know the more they hoard, the longer it will take to sync. Maybe they have data off on purpose.

2018-11-07 02-41-33
André Dinis

The challenge with SyncOnOnline is that they may never actually go offline; they simply have a very weak signal, so the event detecting the change of status from offline to online may never be triggered.

I do want to send the photos. However, I also want to keep them available on the device, at least for some time.

Ok, I got it. I need to find a way to give as much feedback as possible to the user.

Thanks again for your input.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.