I've been implementing a flexible file storage system for Django for my own use (hacked in on top of the existing file field) and would be happy to make this code available if you have any interest in it. I honestly didn't know someone was working in this area or I would have gotten involved sooner.
The code allows you specify file storage "strategies" (which are just classes that conform to an "interface") and specify them in the field constructor. A feature of my implementation that I think works out well is that a special descriptor is added to the model objects to provide access to the file. For example, with the following code: http://dpaste.com/hold/56439/ Instances of this model will be augmented with an additional field "file", as specified in the field constructor, that returns a "FileWithMetaData" wrapper containing the filename, file data and a dict of addition meta data while The file_id field on the model stores a "key" or UUID used to retrieve the file from whatever strategy is being used. This descriptor also allows setting (and deleting). # returns a FileWithMetaData object file = my_object.file # get the original filename orig_name = file.filename # replaces the original file and updates "file_id" my_object.file = new FileWithMetaData("document.pdf", fp.read(), metadata={"owner": "John Q. Public"}) # deletes the file from storage my_object.file = None As I said, the current field implementation itself is a little hackish because it was designed to integrate with the existing oldforms admin without modification and overrides "_save_FIELD_file", etc. - Justin Driscoll On Jun 12, 12:25 pm, David Larlet <[EMAIL PROTECTED]> wrote: > Le 9 juin 08 à 19:11, Marty Alchin a écrit : > > > I've been fairly quiet on the file storage front for a while, since > > it's basically done now, and is just waiting on the streaming upload > > ticket to hit trunk first. Since I got to that point, however, I've > > had two different people, working on two different storage backends, > > both approach me with the same question. It doesn't seem like a > > showstopper to me, but I'd definitely like to get it addressed. I've > > been mulling it over for a while now and can't come up with a > > universally "good" solution, so I'd like to bring it to the group for > > discussion. > > Unfortunately, I hadn't found any elegant solution since our last > discussion. > > > * Storage systems take the name that the model knows about and maps it > > to an actual storage mechanism. This way, each site is free to decide > > how and where its files are stored and retrieved, independent of any > > specific model. > > About Storages, I eventually setup a repository which is more flexible > than ticket #6390http://code.larlet.fr/django-storages/ > There is already the S3 one and I'll work on the FTPStorage soon. Hope > it helps, let me know if there are other storages in progress. > > Cheers, > David --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---