Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: dealing with attachments (again)

by httptech (Chaplain)
on May 25, 2000 at 21:09 UTC ( [id://14815]=note: print w/replies, xml ) Need Help??

in reply to dealing with attachments (again)

Look at my snippet for extracting MIME attachments, it may be helpful.

While you could store binary data in MySQL, I can't think of a good reason to do so. If the attachments are so big you don't want to store them in memory, they will probably be too big to move in and out of MySQL also.

Use my snippet to save the attachments to the server, then save the path to MySQL instead.

Replies are listed 'Best First'.
RE: Re: dealing with attachments (again)
by BBQ (Curate) on May 25, 2000 at 23:22 UTC
    I second that. You would be increasing your performance by a great deal just by finding a clever way to keep the attachments directly on the filesystem. I would suppose that you have a user primary key and a message primary key, correct? If so, you could try doing a directory tree like:
    /users/ /user1/ /attachmenta /attachmentb /attachmentc /user2/ /attachmenta /attachmentb /attachmentc
    Where userx would be the user pk and attachmentx would be the attachment pk (doh!). On the downside, it would probably be nice to develop a tool or cron job to keep track of lost attachments, old stuff and so forth...

    # Trust no1!
      Well, my main concerns were:

      - I need to be able to figure out the ammount of disk space that a user is using, in a fast and easy way.
      - There is a security problem with saving the attachments on a public_html directory.
      - (this is the most important) I'd like to have all the database in one place.

      So there is no way to send the content of a _big_ file to mysql without using a lot of ram?


RE: Re: dealing with attachments (again)
by Punto (Scribe) on May 26, 2000 at 11:01 UTC

    1 question about the code: what happends if the file alredy exists on the temp. directory? it looks like the mime::parser object is creating the file.. how do I get the object not to overwrite the existing file?


      Yes, it does overwrite existing files. You could probably change this behavior by writing a subclass for Mime::Parser to override some of the built-in functions it uses where the filename is determined, but that's beyond the scope of a snippet I think.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://14815]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2024-06-19 12:53 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.