Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 90010 invoked from network); 21 Oct 2009 14:20:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 21 Oct 2009 14:20:25 -0000 Received: (qmail 81386 invoked by uid 500); 21 Oct 2009 14:20:24 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 81296 invoked by uid 500); 21 Oct 2009 14:20:23 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 81286 invoked by uid 99); 21 Oct 2009 14:20:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Oct 2009 14:20:23 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of davisford@gmail.com designates 209.85.221.183 as permitted sender) Received: from [209.85.221.183] (HELO mail-qy0-f183.google.com) (209.85.221.183) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Oct 2009 14:20:13 +0000 Received: by qyk13 with SMTP id 13so2797743qyk.27 for ; Wed, 21 Oct 2009 07:19:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type; bh=xP92NLZeSYuRcFoAb2+ZTYYSf5DIx9HMk5xbwrTq29k=; b=igG53Yb2JB0/vYsU9q4j0L1hayFvAOcD5JPzLboIrwjk8AqqJrvirUJ/QM7lbCHbWx vfdXGp65qD/m0LcjMGqe3XtTXHr07FYjEKafrZJfJ/EvHOX4ynuxQDBdWtEc5Nqusbc5 q4Jm4k32a5uoMIuQIJkuE+iBWLLEX8ghNU+3M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; b=qgkhj47RHEJ1nqBJ00az+o8IzNv+Ht1Q0LwRCvibnl9Ko3BfX4TfZOy0pw9dLCTknO PMaxubDP6JfojeseOP0re4UkNQ5VZMB2mJ55iYrJRcCFvjSopZ3XCpVRREyFevIERDVT zvVm/s1F0kb5/qchTz3s5fsT4Ve6EA9Qz+rUU= MIME-Version: 1.0 Sender: davisford@gmail.com Received: by 10.229.119.131 with SMTP id z3mr1078693qcq.37.1256134792468; Wed, 21 Oct 2009 07:19:52 -0700 (PDT) In-Reply-To: <16d6c6200910202208ob2ddd40y480c5b0950d2e518@mail.gmail.com> References: <9b5c3a2f0910190906u2883e428h265ea0c47962ec22@mail.gmail.com> <9b5c3a2f0910201022o26f7aef3te491e83eeee8a76@mail.gmail.com> <16d6c6200910202208ob2ddd40y480c5b0950d2e518@mail.gmail.com> Date: Wed, 21 Oct 2009 10:19:52 -0400 X-Google-Sender-Auth: 4a4e0fe2587d1b2d Message-ID: <9b5c3a2f0910210719u2dacd7b7kdd5340308f4b36f9@mail.gmail.com> Subject: Re: FileCleanerCleanup question From: Davis Ford To: Commons Users List Content-Type: multipart/alternative; boundary=000e0cd5cc5618614e047672acd5 X-Virus-Checked: Checked by ClamAV on apache.org --000e0cd5cc5618614e047672acd5 Content-Type: text/plain; charset=ISO-8859-1 Hi Martin - I was aware that you could set this threshold in the DiskFileItemFactory -- however, regardless of what I set the value to, it seems that the form's textbox values would be translated into DiskFileItem(s) which would be persisted to a temp file. In the end, I just set the threshold to something very large so the factory never writes to disk, and I manage everything myself. I had three major issues: 1) Stop persisting form fields 2) FileCleanerCleanup was not working to clean up files when a session expired 3) File management was really flaky (e.g. some files would disappear as soon as I uploaded a new file). Writing my own code to persist the files and then setting the FileCleanerCleanup#track on them specifically solves all my problems. Regards, Davis On Wed, Oct 21, 2009 at 1:08 AM, Martin Cooper wrote: > On Tue, Oct 20, 2009 at 10:22 AM, Davis Ford > wrote: > > Hi, is anyone on this list familiar with commons-io / commons-fileupload? > > > > If not, is there somewhere else I should be asking questions? > > > > I still have the issue indicated below, and I have an additional > question. > > > > When you parse the request... => > > > > final List items = (List) > upload.parseRequest(request); > > > > commons-fileupload also generates files for form field items (e.g. text > box > > values). This is an undesired side effect. I want it to generate a file > > for the actual file that is uploaded, but not the form fields. Is there > a > > way to control that? > > Whether a file is created depends on whether the size is over the > (customisable) threshold. Below the threshold, the item's content will > be kept in memory; above the threshold, it will be written to disk. If > that's not flexible enough for your needs, you can provide your own > FileItem class and your own factory to instantiate it. > > -- > Martin Cooper > > > > > > Thanks in advance, > > Davis > > > > > > On Mon, Oct 19, 2009 at 12:06 PM, Davis Ford > > wrote: > > > >> Hi, it is my understanding from the commons-io javadoc, that if you > create > >> a FileCleanerCleanup it will remove files in a directory once the > reference > >> to the File is GC'd. > >> > >> Given that, I'm using commons-fileupload, and I set the listener in > web.xml > >> as: > >> > >> > >> > >> > org.apache.commons.fileupload.servlet.FileCleanerCleanup > >> > >> > >> In my servlet, I have this: > >> > >> private static FileCleaningTracker tracker; > >> > >> @Override > >> protected void initServletContext(ServletContext servletContext) { > >> super.initServletContext(servletContext); > >> tracker = > >> FileCleanerCleanup.getFileCleaningTracker(servletContext); > >> } > >> > >> ...and in my method that accepts a file upload, I add the > >> FileCleanerCleanup: > >> > >> final DiskFileItemFactory factory = new DiskFileItemFactory(0, tempDir); > >> factory.setFileCleaningTracker(tracker); > >> final ServletFileUpload upload = new ServletFileUpload(factory); > >> > >> My files are uploaded and stored in the temp directory as expected. In > the > >> processing of a file upload, I store the FileItem object in the session > as > >> an attribute. Now, if the session expires, I expect the attribute to be > >> GC'd and as a result, the FileCleanerCleanup would go and cleanup the > >> directory, but it does not. > >> > >> Can anyone tell me what I may be doing wrong? > >> > >> Thanks in advance, > >> Davis > >> > >> > >> > > > > > > -- > > Zeno Consulting, Inc. > > home: http://www.zenoconsulting.biz > > blog: http://zenoconsulting.wikidot.com > > p: 248.894.4922 > > f: 313.884.2977 > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org > For additional commands, e-mail: user-help@commons.apache.org > > -- Zeno Consulting, Inc. home: http://www.zenoconsulting.biz blog: http://zenoconsulting.wikidot.com p: 248.894.4922 f: 313.884.2977 --000e0cd5cc5618614e047672acd5--