On Wed, Aug 27, 2008 at 1:16 PM, mwebs <[EMAIL PROTECTED]> wrote:
>
> Thanks for your help.
>
> Datafile is a model and just contains a CharField, a FileField a
> ForeignKey and some Booleanfields.
> -----------------------------------------------
> class DataFile(models.Model):
> name = models.CharField(max_length=255, null = True)
> file = models.FileField(upload_to="data", blank = True, null=True)
> experiment = models.ForeignKey(Experiment)
> ready = models.BooleanField(null = True) # indicates if
> file is already labeled
> uploading = models.BooleanField(null = True) # indicates if
> file is still uploading
> ----------------------------------------------
>
> In my view I just try to use the temporaryFileUploadHandler(). Former
> I used my own Subclass, but to be sure I just
> used the django-native one. This is how I perform the upload:
> -----------------------------------------------------
> ....
> def upload(request, id):
> form = FileForm()
> experiment = get_object_or_404(Experiment, pk=id)
>
> request.upload_handlers = [TemporaryFileUploadHandler()]
>
> if request.method == 'POST' and request.FILES:
> form = FileForm(request.POST, request.FILES)
> if form.is_valid():
> datafile = DataFile(experiment = experiment,
> name = "test",
> file = form.cleaned_data['file'])
> datafile.file.save('test.txt', request.FILES['file'],
> save=False)
> datafile.save()
> -----------------------------------------------------------
>
> I am using revision 1.0 beta 2 -8626 (XP SP2). The code is realy
> simple. The only thing I am doing is to use the
> TemporaryUploadHandler. And as result I have the >200 files in my
> media-directory.
>
> When I wrote the first post, I had the old djangoversion and with that
> I got the windows-error(because the filename was longer than 215).
>
> With the new version I dont get this error, but it seems as if the
> server gets stuck in an endlessloop. It just idles there.
> Further I tried to change FILE_UPLOAD_TEMP_DIR = PROJECT_HTDOCS + '/
> media/temp/'
> Same result, more than 200 copies in my directory.
>
>
I cannot recreate this behavior with a view I built along the lines you
describe. I am able to upload a file fine. The 2nd file I upload has an
underscore appended to its name since "test.txt" already exists and that
name is hardcoded in the view. Likewise the 3rd gets two underscores, 4th
3, etc. So I can see maybe a problem if you already have all those files
and the upload handler never succeeds in finding a name that works? So --
did you clean out all those extra files with underscores after updating to
the latest Django and before trying the upload again?
Karen
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---