Search code examples
djangopython-3.xgoogle-app-enginegcloudtmp

How to store in and access from , GAE /tmp to Django html?


I found this link that says we can use /tmp to store files for our instance in Google App Engine. https://cloud.google.com/appengine/docs/standard/python3/using-temp-files

But the problem is that

1) How do i store to the \tmp folder, is it by just writing the save path as = "\tmp" or something else

2) How will i access those files stored in the \tmp folder in my django html page, currently i can assess the static files using {% static %} tag


Solution

  • Answering your question.

    1. Yes, you just write saving the path as \tmp as you mentioned. As the documentation you provided informs, you should use standard functions to write on these files, so you should be good to go.
    2. You need to read them as you would need any other file from your application. The methods and functions are the same and you should just you the same path.

    In addition to that, I would like to give you a piece of advice (in case you don't yet about it), of something that might be useful to you. As mentioned in the documentation Using Cloud Storage:

    App Engine creates a default bucket when you create an app. This bucket provides the first 5GB of storage for free and includes a free quota for Cloud Storage I/O operations. You can create other Cloud Storage buckets, but only the default bucket includes the first 5GB of storage for free.

    So, this means that you can use this free bucket for access to these files that you want to set in the temporary, for easier management of the files. You can access more information on this other Community post.

    Let me know if the information helped you!