[Zope] one time downloads
Thu, 19 Jun 2003 15:33:59 -0400
On Wed, 18 Jun 2003 10:51:38 -0700 (PDT)
Ed Colmar <email@example.com> wrote:
> Hey fellow zope fiends.
> I've got a little project I'm working on that involves setting up
> multiple one-time downloads.
> I'm curious if anyone out there has done something similar that would
> like to share ideas and or code.
> My concept was to have all the files in a secure directory somewhere.
> Make a temporary directory somewhere with a random id
> "oahnw3487cfyawcry7baw385vbyawy348vyaw" or whatever... Set the
> directory name and a flag into a db somewhere. Then after the
> download is complete(or after a certain amount of time, delete the dir
> and the files.
Yes, it is not real hard. You will probably need an external method.
Here is what I do, more or less:
import sha, os
my_secret='Put your site secret string here'
f_base='absolute path to file base'
def upload(self, name, attachment):
# make sure index.html is there
# to block people from simply reading the directory
if not os.access(f_base+'/index.html', os.F_OK):
fpth=f_base+name+hx+'.html' # or whatever extension
if not s:
once = 1
Then you can use fpth to compose your email, athough you probably
actually want to construct an URL, not a file path.
And a simple cron job can take care of cleaning the directory for you
periodically. Just try to avoid deleting index.html.
> Anyone have something like this already?
> Green Graphics ::: Print and Web Design ::: 510.923.0000
> Zope maillist - Zope@zope.org
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://mail.zope.org/mailman/listinfo/zope-dev )