SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2002
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Inserting binary data within MySQL...

    I was just wondering. I'm currently inserting binary data into my MySQL database by taking the file, opening it, reading it's contents and then streaming it into the db. This presents alot of overhead and larger files. Is there a more practical way to do this?

    If so, could any one give some pointers? I would be forever thankful!

  2. #2
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you inserting images?? if so store the image on your fileserver and store a link in the database...

    Peanuts
    the neigbours (free) WIFI makes it just a little more fun

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Kampala Uganda
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi;
    i could help you on this problem but it's unfortunate am leaving right now! send me a PM reminding me of the thread number so that i get back to you otherwise i have gone through the same experience at one time and had a solution to it.
    Hear From you Soon.
    Vien
    And we know that all things work together for good
    To them that love God, to them who are the called
    According to his purpose. Romans 8:28

  4. #4
    SitePoint Zealot poLka's Avatar
    Join Date
    Apr 2003
    Location
    GF
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when would you actually want to store an image in a DB? storing the URL seems more practical (good advice peanuts)

  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2002
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I never said I was storing images within the db. I am storing digital products for sale; small compressed files. This is pretty much the only fool proof way of keeping snoopers from stealing your stuff.

    There are other countermeasures too that make everything foolproof, but I was just wondering if there was a more practical way of doing this.

    In the end I'll probably skip this and create a products folder beneath root and store everything there having a script copy them to and fro for me.

  6. #6
    SitePoint Zealot poLka's Avatar
    Join Date
    Apr 2003
    Location
    GF
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh dude, i'm sorry... i didn't mean to point that at you so harshly... i was really just askin a new question. youdaman!

  7. #7
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, storing it below the root, and then readfile()'ing it to the user is a secure method to restrict access, as well as save you the overhead of storing large files in the database.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  8. #8
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Kampala Uganda
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Polka, Consider cases where you have a forum and you would want your users to avail there avators or cases where you want to exchange banners for bussiness adverts. Here you allow theuser attach there avators/banners now these details must then therefore stored in the database. Does this give you a more practicle view?
    And we know that all things work together for good
    To them that love God, to them who are the called
    According to his purpose. Romans 8:28

  9. #9
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Kampala Uganda
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post RE: Store File!

    Hi
    cyborg from dh's advice was a better one i guess! On additional to it i will add you afew security hints:.
    To Secure your data you could make that folder you created to store your files not viewable to the Globe{0}.
    This way it will only be you fread()'ing and fwriting()'ing!.
    And we know that all things work together for good
    To them that love God, to them who are the called
    According to his purpose. Romans 8:28

  10. #10
    SitePoint Zealot poLka's Avatar
    Join Date
    Apr 2003
    Location
    GF
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks vien... i'm starting to get all this (slowly of course!)

  11. #11
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cyborg from dh
    Yes, storing it below the root, and then readfile()'ing it to the user is a secure method to restrict access, as well as save you the overhead of storing large files in the database.
    You don't exactly save overhead, you sort of transfer overhead. Less overhead on the database, more overhead on the filesystem.

    One benefit to storing directly in the database might be that you don't need to worry about the references getting out of whack with the actual files.

    I don't really know how well it works one way or the other. I know it works both ways, but I really can't say which is better or worse. I think the fread(fileLocation) approach is rhetorically considered better, but that may just be because it is more simple in some ways (simple is definitely a plus).
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •