Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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...

    #!/home/bbq/bin/perl
    # 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?

      Thanks!

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

    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?

    Thanks..

      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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2025-06-17 16:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.