On Wed, Sep 9, 2009 at 7:41 AM, Esteban Masoero <emaso...@getsense.com.ar>wrote:

> Hi uudashr, I gotta tell you've done terrific work! I tried it in my
> wicket-GAE app and it worked :)
>
> Comments/questions:
>
> About wicket framework:
> 1- Is it possibly that the MultipartServletWebRequest can have this line:
> DiskFileItemFactory factory = new DiskFileItemFactory();
> ...changed for...
> DiskFileItemFactory factory = getFileItemFactory(); // and this would be a
> protected method that would instanciate the DiskFileItemFactory by default
> If that change could be done, instead of generate an exact copy of
> MultipartServletWebRequest with that line different, we could just extend it
> and override getFileItemFactory() method.
>
> Yes of course, that would be good idea. To do that we have to modify the
wicket code, you have to ask that to wicket team.


> 2- Once this code is properly review, where should be added? I'm not sure
> that the wicket base framework would be the best place. But what about some
> kind of wicket-gae-extension?
>
> About your code:
> 1- In the classic "onSubmit()" in a form, what's the way I should store the
> final file?
> a) OutputStream fos = new DatastoreOutputStream(fileName);
> fos.write(fileUpload.getInputStream().toByteArray()) (y tried this option
> first and it didn't work, but i'm not sure I used it the right way)
>
Strange, I didn't have toByteArray() method on InputStream. Just read it
from input stream and write it to DataStoreOutputStream. Doing toByteArray()
might bad idea, you can load big amount data on the memory if it's a big
file size.

b) FileStorage.instance().write(fileUpload.getInputStream(), filename);
> (this option worked :))
>
> 2- I also found an "issue" related to the DATA_CHUNK_SIZE.
> In your code this is declared as DATA_CHUNK_SIZE =
> (int)(Bytes.megabytes(1).bytes() - Bytes.kilobytes(10).bytes());

In development environment worked fine, however, when using in production
> environment (google's magic servers), an error ocurred. I didn't copy the
> stack trace, but it said that the maximun entity (or property, can't
> remember) size had been reached for the field "data" (which of course has
> the file data). It said the maximun was "1000000 characters" (actually less
> than a Megabyte?, which should be 1024*1024bytes?, maybe google app engine
> documentation needs a fix, not quite sure about this). And strangely, in
> that case the file uploaded had a size of 14Kb.
>
> Finally, we reduced DATA_CHUNK_SIZE to 512Kb, and it worked fine. Anyway, I
> wanted to let you know so you can take a look.
>
> Not sure what happen to you, but it works for me.

>
> Regards!
>
>
> Daniele Dellafiore escribió:
>
>  Great, seems interesting, I will give this a try. Thanks.
>>
>> On Sun, Aug 30, 2009 at 6:31 PM, uud ashr <uuda...@gmail.com> wrote:
>>
>>
>>
>>> Hi all
>>> Just want to share.
>>> If you have problem with file upload on Google App Engine, I just done
>>> some
>>> experiment and it works.
>>> Use the attached files.
>>> I didn't create this, I just modify from the existing wicket source code.
>>>
>>> I create new class, GaeSafeServletWebRequest which is subclass of
>>> ServletWebRequest. Everyting come from here.
>>>
>>> The key is remove the thread that clean the ReferenceQueue. So how to
>>> clean
>>> it? I use something called FileCleaner.reapFiles(2) that will poll the
>>> queue
>>> maximum 2 item. I put those line of code everytime
>>> GaeSafeServletWebRequest
>>> created.
>>>
>>> to use, you only need to override method *newWebRequest* on your wicket
>>> application
>>>
>>>    @Override
>>>
>>>    protected WebRequest newWebRequest(final HttpServletRequest
>>> servletRequest) {
>>>
>>>        return new GaeSafeServletWebRequest(servletRequest);
>>>
>>>    }
>>>
>>>
>>> When you upload something, then write it using *DatastoreOutputStream*,
>>> it
>>> will put all the bytes to GAE (Google App Engine) datastore. This
>>> OutputStream already handle the over size, so it will create chunk files
>>> in
>>> order to save the big file size.
>>>
>>> Please tell me if it works for you (actually it works for me) and maybe
>>> we
>>> can refine or create the better code. Or maybe we can add this to wicket?
>>> So
>>> wicket can be "FULL COMPATIBLE" to Google App Engine.
>>>
>>> Regards,
>>> uudashr
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>>> For additional commands, e-mail: users-h...@wicket.apache.org
>>>
>>>
>>>
>>
>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to