Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question Datastore: Best practice to store static files #865

Closed
chris-mds opened this issue Nov 2, 2020 · 3 comments
Closed

Question Datastore: Best practice to store static files #865

chris-mds opened this issue Nov 2, 2020 · 3 comments
Labels
datastore Issues related to the DataStore category question General question

Comments

@chris-mds
Copy link

chris-mds commented Nov 2, 2020

We are using Datastore inside our app to get offline capability, which works really well.
Now we want to implement possibilities to capture images offline and upload it to the cloud, when a valid connection is established.
My suggestion is to store images on the local disc and listen to the Amplify.Hub to trigger some kind of upload function, when the hub invokes syncing. Is there maybe a better approach or even a best practice?

@palpatim palpatim added datastore Issues related to the DataStore category question General question labels Nov 2, 2020
@palpatim
Copy link
Member

palpatim commented Nov 2, 2020

If you're uploading files to the cloud, you'll want to investigate Amplify Storage. You can listen to the Amplify Hub events and then trigger appropriate Storage operations when the sync starts. We're working on a PR that will better explain the Hub Events so you can find the right one for your needs--my initial thought is that you'd want to listen for syncQueriesReady to ensure that all your model changes are up to date locally.

As far as best practices go: since we don't support Complex Objects in DataStore, it's really up to you how you want to reference the objects to the DataStore record. At a bare minimum, you'll need something by which you can derive the object's key, and you'll need to make sure your app uploads the object with appropriate access levels (protected, private, public) for your use case. Make sure you know how you want to handle error cases and consistency as well: e.g., should you wait to fire a mutation until the upload succeeds? Should a data model be changed to reflect a new status if the upload fails? Or are the objects and models loosely coupled enough that they don't need to be synchronized?

Hope this helps.

@chris-mds
Copy link
Author

Hi @palpatim ,
Thank you for your answer. Is this topic on your roadmap to support static files with offline capabilities as well?

@drochetti
Copy link
Contributor

drochetti commented Nov 4, 2020

Hi @palpatim ,
Thank you for your answer. Is this topic on your roadmap to support static files with offline capabilities as well?

It is, we don't have an ETA yet but we're actively evaluating that feature. This issue is related to the same feature request #799

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datastore Issues related to the DataStore category question General question
Projects
None yet
Development

No branches or pull requests

3 participants