Is it different to store account in dotenv and other source code files? - dotenv

Most of them keep tokens or accounts separately in the dotenv file.
is it different from just saving it as a variable in another source code file and import it for use?
I've been studying API these days, and I've been wondering how to store sensitive content.

Related

Specify the GCP project in tf.io.GFile()

Is there a way how to specify the GCP project for downloading some objects using the tf.io.gfile.GFile? I know it can be used like this:
import tensorflow as tf
with tf.io.gfile.GFile("gs://<bucket>/<path>") as f:
f.read()
but this does not have any parameter for project. I know you can select active project using the CLI tools, but I want to download data from different projects. Is it possible, or do I need to use some other GCS client? If so, which is the most compatible with TF and can be most easily used in tf.function?
Buckets are unique across projects, so although you see only buckets created as a part of a project on the https://console.cloud.google.com/storage/browser?project=<project>&prefix=&forceOnObjectsSortingFiltering=false page, you can query it regardless of the project, so as long as you have access there, you just can access the data without specifying project.

Should I use AsyncStorage for large amounts of data?

We are wanting to implement an offline mode for our react-native application. We will be working with quite large amount of data (aprox. 40-50mb). It is an array of aprox. 16000 objects.
As far as I know, there are two ways to save this data.
Using AsyncStorage - android has a limit of 6mb, but I've read somewhere, that it can be increased.
Using json file - Downloading that data as json file using react-native-background-downloader and then using react-native-fs to save it and load it if the user has no connection to internet.
Personally I think that the second option is better, even though it requires permission to file storage.
Am I missing any other factors to consider? Are there any other options for offline access?
In the end opted out for usage of the json file as there is limit on android. On load of the application I take these data and load them into variable in mobX store. Which functions same as any variable.
I was afraid that mobile phones will have problem sorting across the 16000 objects in array, but there have been no reports of this thing going wrong so far. (In production for 4-5 months right now)
So basically when you hit "enable offline mode" I ask for the file storage permission and download the file using react-native-fs.
Then on the next startup of the application I just read the data off the JSON file.

How to import data to sembast flutter?

I'm developing mobile app on flutter and now selecting a database. I'm thinking about sembast (https://pub.dev/packages/sembast#-readme-tab-), but there is no information about importing (preloading) data to the database.
Does anyone know that? Should I add csv or json files with data to asset and then somehow load it into the database? In comparison, there is sqflite package from the same author (https://pub.dev/packages/sqflite#-readme-tab-) and here I can add sqlite database to asset and then import it into the project.
Sembast is not flutter only so there is no specific mention about asset file.
One solution is to preload data using the basic versioning system:
https://github.com/tekartik/sembast.dart/blob/master/sembast/doc/open.md#preloading-data
Or to import data (reading an exported map from an asset file):
https://github.com/tekartik/sembast.dart/blob/master/sembast/doc/storage_format.md#importexport

Accessing Dropbox Datastore database

I use an outdated iOS app called Loggr, and now would like to extract data stored in it. It syncs with Dropbox Datastore, which I can see on my Dropbox account:
But I cant find any files corresponding to among my Dropbox files. My question, how do I extract the information from the Datastore?
Dropbox Datastores are a structured data storage system, separate from files, so they won't appear as files in your account. They should be available under "Apps you use" here though:
https://www.dropbox.com/developers/apps/datastores

File permissions on a web server?

I'm new at writing code for websites. The website allows users to upload files, such as profile pictures or other pictures. The files are saved in the unix file system and the URLs to find those images are stored in a MySQL database.
It seems like the only way I can let the user upload files is to give write access to anybody using chmod. Otherwise it complains that it doesn't have write permissions. But they shouldn't be able to write whatever they want or overwrite other users stuff. Similarly, to allow users to see images that they have rightful access to, they need read permissions on the file system. But now that means that anybody with the url to that picture can see the image too, correct? That's not what I want.
Is there a solution to this contradiction? Or am I thinking about the problem incorrectly? Thanks for any help.
You need to manage the permissions in your application and not expose arbitrary parts of your local filesystem directly to the clients. Your application should decide what files someone can see or where to write data. You should not trust data (filenames, etc) from your clients...ideally, store files on disk using systematically generated names and store human-readable names in the database.
SunStar9,
Since you are already using a MySQL database to store the URL of the image on the file system, why not just store the image itself as a BLOB (binary large object)?
This is generally a well-accepted design practice for allowing users to upload binary data to a website.
Are you using PHP, Java, Ruby/Rails, or something other to develop your website? Depending on what you are using, there could be file upload/management plugins or modules that will help you develop what you are trying to do if you are certain you want to use the files ystem for storing the image data.