storage

How do I get Django Admin to delete files when I remove an object from the database/model?

感情迁移 提交于 2019-11-26 04:37:29
问题 I am using 1.2.5 with a standard ImageField and using the built-in storage backend. Files upload fine but when I remove an entry from admin the actual file on the server does not delete. 回答1: You can receive the pre_delete or post_delete signal (see @toto_tico's comment below) and call the delete() method on the FileField object, thus (in models.py): class MyModel(models.Model): file = models.FileField() ... # Receive the pre_delete signal and delete the file associated with the model

Android create folders in Internal Memory

空扰寡人 提交于 2019-11-26 03:58:21
问题 Is there any way/ is it allowed to create folders in Internal Memory in Android. Example : - data -- com.test.app (application\'s main package) ---databases (database files) ---files (private files for application) ---shared_prefs (shared preferences) ---users (folder which I want to create) Can I create users folder in Internal Memory for example? 回答1: I used this to create folder/file in internal memory : File mydir = context.getDir("mydir", Context.MODE_PRIVATE); //Creating an internal dir

Making sense of Postgres row sizes

Deadly 提交于 2019-11-26 03:40:27
问题 I got a large (>100M rows) Postgres table with structure {integer, integer, integer, timestamp without time zone}. I expected the size of a row to be 3*integer + 1*timestamp = 3*4 + 1*8 = 20 bytes. In reality the row size is pg_relation_size(tbl) / count(*) = 52 bytes. Why? (No deletes are done against the table: pg_relation_size(tbl, \'fsm\') ~= 0) 回答1: Calculation of row size is much more complex than that. Storage is typically partitioned in 8 kB data pages . There is a small fixed

Core Data - Storing Images (iPhone) [closed]

六眼飞鱼酱① 提交于 2019-11-26 02:27:23
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 12 months ago . I have an application where I allow the user to add an image for their account. I wish to know how to store an image (obtained from the camera or photo library) using Core Data , as I may offer a backup facility for the user and would be looking to transfer the image data to a

Storing a file in a database as opposed to the file system?

跟風遠走 提交于 2019-11-26 01:39:19
问题 Generally, how bad of a performance hit is storing a file in a database (specifically mssql) as opposed to the file system? I can\'t come up with a reason outside of application portability that I would want to store my files as varbinaries in SQL Server. 回答1: Have a look at this answer: Storing Images in DB - Yea or Nay? Essentially, the space and performance hit can be quite big, depending on the number of users. Also, keep in mind that Web servers are cheap and you can easily add more to

What are the main performance differences between varchar and nvarchar SQL Server data types?

走远了吗. 提交于 2019-11-26 01:34:59
问题 I\'m working on a database for a small web app at my school using SQL Server 2005 . I see a couple of schools of thought on the issue of varchar vs nvarchar : Use varchar unless you deal with a lot of internationalized data, then use nvarchar . Just use nvarchar for everything. I\'m beginning to see the merits of view 2. I know that nvarchar does take up twice as much space, but that isn\'t necessarily a huge deal since this is only going to store data for a few hundred students. To me it

Android: Storing username and password?

ぃ、小莉子 提交于 2019-11-26 00:39:56
问题 If I want to store the username and password to be used inside an Android application, what is the best way to do it? Is it through the preferences screen (but what if the user misses this?), or pop up a dialog box and ask the user for the credentials? If so, I do have to maintain state for the application. How would I do this? 回答1: Most Android and iPhone apps I have seen use an initial screen or dialog box to ask for credentials. I think it is cumbersome for the user to have to re-enter

Android saving file to external storage

ⅰ亾dé卋堺 提交于 2019-11-26 00:00:03
问题 I have a little issue with creating a directory and saving a file to it on my android application. I\'m using this piece of code to do this : String filename = \"MyApp/MediaTag/MediaTag-\"+objectId+\".png\"; File file = new File(Environment.getExternalStorageDirectory(), filename); FileOutputStream fos; fos = new FileOutputStream(file); fos.write(mediaTagBuffer); fos.flush(); fos.close(); But it\'s throwing an exception : java.io.FileNotFoundException: /mnt/sdcard/MyApp/MediaCard/MediaCard-0

Calculating and saving space in PostgreSQL

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-25 23:07:35
问题 I have a table in pg like so: CREATE TABLE t ( a BIGSERIAL NOT NULL, -- 8 b b SMALLINT, -- 2 b c SMALLINT, -- 2 b d REAL, -- 4 b e REAL, -- 4 b f REAL, -- 4 b g INTEGER, -- 4 b h REAL, -- 4 b i REAL, -- 4 b j SMALLINT, -- 2 b k INTEGER, -- 4 b l INTEGER, -- 4 b m REAL, -- 4 b CONSTRAINT a_pkey PRIMARY KEY (a) ); The above adds up to 50 bytes per row. My experience is that I need another 40% to 50% for system overhead, without even any user-created indexes to the above. So, about 75 bytes per

Storing Images in DB - Yea or Nay?

情到浓时终转凉″ 提交于 2019-11-25 21:32:15
问题 So I\'m using an app that stores images heavily in the DB. What\'s your outlook on this? I\'m more of a type to store the location in the filesystem, than store it directly in the DB. What do you think are the pros/cons? 回答1: I'm in charge of some applications that manage many TB of images. We've found that storing file paths in the database to be best. There are a couple of issues: database storage is usually more expensive than file system storage you can super-accelerate file system access