Hello All!
I created a simple app, which uses a static file uploaded in the Data Files service in the anvil.works dev build enviromnent. Everything works as planned and the file is accessible in the server code, by referring to ‘data_files’ variable.
Then, I installed the anvil-app-server locally and cloned my app to it. But when I use a function to access the static file (using the ‘data_files’ variable again), the app displays an error: “file not found”.
I assume the static data files are not actually cloned when the app is git-cloned locally?
How to work around this? Should the static files be uploaded separately to the app-server, and if yes, then where exactly?
Thank You!
Files stored via the Data Files service are not stored statically, as part of the source tree, but are actually stored in the database.
I understand they are stored as some blobs in the database, but as I understand, I should still be able to access them still via ‘data_files’ global variable. When I do this from the anvil.works development environment, it works fine. But when I do this after running the server locally, I get an error “file not found”…
Are those files in your local server’s database, in its table Files?
I guess probably not, although I haven’t derived a way to look at the database content while I run the app locally. I assume I have to store the files again on the local server’s database, but I don’t know how to do it…
During development in anvil.works, you have a nice GUI to upload the static data files, but there’s no such thing on the local server…
Sorry if I ask noob questions, I’m only starting to learn anvil
)
Everybody starts that way, so no worries! This is one reason why I’m going slow, one question at a time.
The other is that I have not tried local hosting. Other forum readers have, and can probably answer your latest question a lot better.
In the absence of an Anvil IDE, you can still add an Upload feature to your App. You might also write an Uplink program or two, to do your own database maintenance.
Uplink programs typically run on your own hardware. They can call your App’s Server functions, and can connect to your App’s database, to work with it the same way your Server code would do.
I was thinking about using Uplink, but I need the uploaded files to be available to all users of the app, and I’m not sure that Uplink works that way. Also I got the impression that Uplink only works when your app is hosted on Anvil servers, but not locally.
I will read more about Uplink, but I’m still hoping someone can give a more clear answer what to do when wanting to permanently store the files while hosting the app locally…
IIRC, using Uplink to connect to your local Anvil installation was covered in a recent Forum post. You might try using Search to find it.
You wouldn’t be using Uplink to serve the files. Rather, you’d be using Uplink to add the files to your local Files table, just as they appear in your hosted Files table. That way, your local App and your hosted App would both see the same Files Service contents.