PloneFormGen and binary file upload

10 messages Options
Embed this post
Permalink
Ralf Hemmecke-2 () PloneFormGen and binary file upload
Reply Threaded More More options
Print post
Permalink
Hello,

I would like to use PloneFormGen to upload PDFs into a special folder of
my site. According to

http://plone.org/plone.org/products/ploneformgen/issues/5

and PFGs current behaviour, the files are not saved with the
SaveDataAdapter. (The MailAdapter is not an option for me, I want the
files automatically in my Plone Site.)

I'll probably have to program something, but I'm almost sure someone has
already done a similar job. Could this person share the code or give
some concrete hints how this can be done or how to narrow my plone
documentation search space.

Thank you in advance.

Ralf

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
ajung () Re: PloneFormGen and binary file upload
Reply Threaded More More options
Print post
Permalink
The save adapter does not support binary uploads. You may combine script + save adapter in order to save the binary content within a custom Plone folder and link it somehow to with the related data within the save adapter.

-aj

Ralf Hemmecke-2 wrote:
Hello,

I would like to use PloneFormGen to upload PDFs into a special folder of
my site. According to

http://plone.org/plone.org/products/ploneformgen/issues/5

and PFGs current behaviour, the files are not saved with the
SaveDataAdapter. (The MailAdapter is not an option for me, I want the
files automatically in my Plone Site.)

I'll probably have to program something, but I'm almost sure someone has
already done a similar job. Could this person share the code or give
some concrete hints how this can be done or how to narrow my plone
documentation search space.

Thank you in advance.

Ralf

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Plone-Users mailing list
Plone-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plone-users
David Hostetler () Re: PloneFormGen and binary file upload
Reply Threaded More More options
Print post
Permalink
In reply to this post by Ralf Hemmecke-2
Is there a particular reason you feel the need to use PFG?   (don't get me wrong, I <3 PFG)

Correctly handling the upload and storage of PDFs (or any other file) as a plone content object is precisely what ATFile is for.  Have you thought about just having a custom page that offers up the equivalent of the 'add new' -> 'File' action?   I.e. using the mechanism behind the following:

http://<your plone site>/createObject?type_name=File

If you stick with PFG, what you'll likely end up doing is using the same mechanism anyway, within a custom external method hooked in as either the success action or the validation.

regards,

-hoss


On Mon, Nov 2, 2009 at 07:47, Ralf Hemmecke <[hidden email]> wrote:
Hello,

I would like to use PloneFormGen to upload PDFs into a special folder of
my site. According to

http://plone.org/plone.org/products/ploneformgen/issues/5

and PFGs current behaviour, the files are not saved with the
SaveDataAdapter. (The MailAdapter is not an option for me, I want the
files automatically in my Plone Site.)

I'll probably have to program something, but I'm almost sure someone has
already done a similar job. Could this person share the code or give
some concrete hints how this can be done or how to narrow my plone
documentation search space.

Thank you in advance.

Ralf

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
Ralf Hemmecke-2 () Re: PloneFormGen and binary file upload
Reply Threaded More More options
Print post
Permalink
OK, maybe I need to describe my use case.

It's an application form.

I've created a form that asks anonymous users to submit name, country,
sex, etc. and picture, CV (in pdf format) and a few other data. (Of
course, I have a captcha field...)

The form works fine with Mail and SaveData Adapter. But I have been
asked to store the PDF's in the plone site for the people who actually
will get access to the data.
It's probably best to collect the files in a folder per applicant.

Anyway, I was already so far to go into the direction that Andreas
suggested, i.e. adding a script adapter, but now I am pretty helpless
since I've not done such things before.

As I said, I'd appreciate code that approximately deals with such an
issue. I cannot be the first who ran into such a use case.

If there is no code, more specific pointers into the documentation would
be highly appreciated. I simply don't know what how to read the file
field and turn it into a file in plone. Some code snippets available to
get me started?

Thank you in advance.

Ralf


On 11/02/2009 03:48 PM, David Hostetler wrote:

> Is there a particular reason you feel the need to use PFG?   (don't get
> me wrong, I <3 PFG)
>
> Correctly handling the upload and storage of PDFs (or any other file) as
> a plone content object is precisely what ATFile is for.  Have you
> thought about just having a custom page that offers up the equivalent of
> the 'add new' -> 'File' action?   I.e. using the mechanism behind the
> following:
>
> http://<your plone site>/createObject?type_name=File
>
> If you stick with PFG, what you'll likely end up doing is using the same
> mechanism anyway, within a custom external method hooked in as either
> the success action or the validation.
>
> regards,
>
> -hoss
>
>
> On Mon, Nov 2, 2009 at 07:47, Ralf Hemmecke <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hello,
>
>     I would like to use PloneFormGen to upload PDFs into a special folder of
>     my site. According to
>
>     http://plone.org/plone.org/products/ploneformgen/issues/5
>
>     and PFGs current behaviour, the files are not saved with the
>     SaveDataAdapter. (The MailAdapter is not an option for me, I want the
>     files automatically in my Plone Site.)
>
>     I'll probably have to program something, but I'm almost sure someone has
>     already done a similar job. Could this person share the code or give
>     some concrete hints how this can be done or how to narrow my plone
>     documentation search space.
>
>     Thank you in advance.
>
>     Ralf

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
matthias broquet () Re: PloneFormGen and binary file upload
Reply Threaded More More options
Print post
Permalink
In reply to this post by ajung
Some javascript/style in this post has been disabled (why?)
Hello,

You may use the atreal-attachment-storage branche of Products.PloneFormGen

http://dev.plone.org/collective/browser/Products.PloneFormGen/branches/atreal-attachment-storage

In this branche, uploaded files are stored within the form as annotations, and can be downloaded via the 'Tabular view' of the Data Recorder.
Be aware this files are simple binary files, not ATFiles.

Regards,

Matthias.
Ralf Hemmecke-2 wrote:
  
Hello,

I would like to use PloneFormGen to upload PDFs into a special folder of 
my site. According to

http://plone.org/plone.org/products/ploneformgen/issues/5

and PFGs current behaviour, the files are not saved with the 
SaveDataAdapter. (The MailAdapter is not an option for me, I want the 
files automatically in my Plone Site.)

I'll probably have to program something, but I'm almost sure someone has 
already done a similar job. Could this person share the code or give 
some concrete hints how this can be done or how to narrow my plone 
documentation search space.

Thank you in advance.

Ralf

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users


    

  


--
atReal

Matthias BROQUET
[hidden email]
Ingénieur d'études

Tel [04 91 29 42 81] - Fax [04 91 29 42 82]
IRC Server [Freenode] Channel [#atreal]

113 bd de Pont-de-Vivaux
13010 MARSEILLE

Solutions Intranet/Extranet/Ged - www.atreal.net
Solutions Collectivités - www.atreal.fr



------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
Yuri-11 () Re: PloneFormGen and binary file upload
Reply Threaded More More options
Print post
Permalink
In reply to this post by Ralf Hemmecke-2
Ralf Hemmecke ha scritto:
> If there is no code, more specific pointers into the documentation would
> be highly appreciated.
create a folder called "archive" on the plone site, under the root (or
in the folder where the form is)

Then just modify the save data adapter. On function onSuccess, on line
287 of saveDataAdapter.py:

change

else:
                        data.append( '%s:%s:%s:Binary upload discarded'
%  (filename, mimetype, enc) )

to

else:

 self.archive.invokeFactory('File', 'a-name')
 self.archive['a-name'].setFile(file)

Should work. I don't know why it is not done by default :)

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
matthias broquet () Re: PloneFormGen and binary file upload
Reply Threaded More More options
Print post
Permalink
In reply to this post by Ralf Hemmecke-2
Some javascript/style in this post has been disabled (why?)
Ralf Hemmecke a écrit :
OK, maybe I need to describe my use case.

It's an application form.

I've created a form that asks anonymous users to submit name, country, 
sex, etc. and picture, CV (in pdf format) and a few other data. (Of 
course, I have a captcha field...)

The form works fine with Mail and SaveData Adapter. But I have been 
asked to store the PDF's in the plone site for the people who actually 
will get access to the data.
It's probably best to collect the files in a folder per applicant.

Anyway, I was already so far to go into the direction that Andreas 
suggested, i.e. adding a script adapter, but now I am pretty helpless 
since I've not done such things before.

As I said, I'd appreciate code that approximately deals with such an 
issue. I cannot be the first who ran into such a use case.

If there is no code, more specific pointers into the documentation would 
be highly appreciated. I simply don't know what how to read the file 
field and turn it into a file in plone. Some code snippets available to 
get me started?

Thank you in advance.

Ralf


  
Hello,

You may use the atreal-attachment-storage branche of Products.PloneFormGen

http://dev.plone.org/collective/browser/Products.PloneFormGen/branches/atreal-attachment-storage

In this branche, uploaded files are stored within the form as annotations, and can be downloaded via the 'Tabular view' of the Data Recorder.
Be aware this files are simple binary files, not ATFiles.

Regards,

Matthias.


--
atReal

Matthias BROQUET
[hidden email]
Ingénieur d'études

Tel [04 91 29 42 81] - Fax [04 91 29 42 82]
IRC Server [Freenode] Channel [#atreal]

113 bd de Pont-de-Vivaux
13010 MARSEILLE

Solutions Intranet/Extranet/Ged - www.atreal.net
Solutions Collectivités - www.atreal.fr



------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
Lars Löwenadler () Re: PloneFormGen and binary file upload
Reply Threaded More More options
Print post
Permalink
In reply to this post by Yuri-11
Yuri-11 wrote:
create a folder called "archive" on the plone site, under the root (or
in the folder where the form is)

Then just modify the save data adapter. On function onSuccess, on line
287 of saveDataAdapter.py:

change

else:
                        data.append( '%s:%s:%s:Binary upload discarded'
%  (filename, mimetype, enc) )

to

else:

 self.archive.invokeFactory('File', 'a-name')
 self.archive['a-name'].setFile(file)

Should work. I don't know why it is not done by default :)
Exactly what were these new lines supposed to do? I'm also possibly interested in tweaking the saveDataAdapter, but editing the file inserting those lines rendered an error when visiting the form. Unfortunately I didn't record the error/log as I promptly reverted to the original .pt file...

Thanks,
Lars
Steve McMahon-2 () Re: PloneFormGen and binary file upload
Reply Threaded More More options
Print post
Permalink
In reply to this post by Ralf Hemmecke-2
Take a look at:

http://plone.org/products/ploneformgen/documentation/how-to/creating-content-from-pfg

The technique described there will make it easy to create files.

On Mon, Nov 2, 2009 at 4:47 AM, Ralf Hemmecke <[hidden email]> wrote:
Hello,

I would like to use PloneFormGen to upload PDFs into a special folder of
my site. According to

http://plone.org/plone.org/products/ploneformgen/issues/5

and PFGs current behaviour, the files are not saved with the
SaveDataAdapter. (The MailAdapter is not an option for me, I want the
files automatically in my Plone Site.)

I'll probably have to program something, but I'm almost sure someone has
already done a similar job. Could this person share the code or give
some concrete hints how this can be done or how to narrow my plone
documentation search space.

Thank you in advance.

Ralf

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
Yuri-11 () Re: PloneFormGen and binary file upload
Reply Threaded More More options
Print post
Permalink
In reply to this post by Lars Löwenadler
Lars Löwenadler ha scritto:

> Yuri-11 wrote:
>  
>> create a folder called "archive" on the plone site, under the root (or
>> in the folder where the form is)
>>
>> Then just modify the save data adapter. On function onSuccess, on line
>> 287 of saveDataAdapter.py:
>>
>> change
>>
>> else:
>>                         data.append( '%s:%s:%s:Binary upload discarded'
>> %  (filename, mimetype, enc) )
>>
>> to
>>
>> else:
>>
>>  self.archive.invokeFactory('File', 'a-name')
>>  self.archive['a-name'].setFile(file)
>>
>> Should work. I don't know why it is not done by default :)
>>
>>    
>
> Exactly what were these new lines supposed to do? I'm also possibly
> interested in tweaking the saveDataAdapter, but editing the file inserting
> those lines rendered an error when visiting the form. Unfortunately I didn't
> record the error/log as I promptly reverted to the original .pt file...
>  

a - do this first on a local plone, not in production
b - On function onSuccess, on line 287 of saveDataAdapter.py

The code is obviously not tested, you've to make it work.

> Thanks,
> Lars
>  


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Plone-Users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users