Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Is Saving File Name is best practice when uploading file?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

One user uploads a unique image i.e company logo which is unique throughout the system.

However user chooses the image from his system and upload it to the server.

Currently we stored the file image in the server as CLOB.

Do we need to save the file name as best practice or it is not needed???

Thanks
 
Saloon Keeper
Posts: 6511
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would generally want to use a filename that is unique, and which relates to the user (maybe by including their ID in the filename). That means you would pick a filename based on your needs, which likely include making filenames predictable. Whether it makes sense to store the original name as well depends on what you and the client might want to do with the image in the future. Offhand, I can't think of a good reason.
 
Sheriff
Posts: 15754
264
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whether or not you save the original file name would depend on the use case, wouldn't it? For example, if the files were images of receipts that the user is submitting for reimbursement, I would think you'd want to keep the original file name so that the user can later review what has been uploaded and see if there are any receipts on their local machine that have yet to be uploaded. On the other hand, I'm sure there are use cases where keeping the original file name doesn't provide any value for the user.
 
Ranch Hand
Posts: 127
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

John Knox wrote:Currently we stored the file image in the server as CLOB.


That doesn'T sound right - C-LOB is for Character Large OBject - storing an image should be done in a B-LOB - a Binary Large OBject ...
 
Tim Moores
Saloon Keeper
Posts: 6511
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, I wouldn't generally recommend storing files in a database. The filesystem is made for that, and if all the metadata is in the DB, you can get at the data required for accessing the file just as easily.
 
Rancher
Posts: 903
22
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim,

Quite right.  I had a project that had 100's of thousands of images and we stored the file name and path in the db, but kept the files in the file system.  Retrieval was actually faster than using BLOBS.

Les

Tim Moores wrote:Also, I wouldn't generally recommend storing files in a database. The filesystem is made for that, and if all the metadata is in the DB, you can get at the data required for accessing the file just as easily.

 
Marshal
Posts: 25671
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Junilu Lacar wrote:Whether or not you save the original file name would depend on the use case, wouldn't it?



Sometimes I suspect that looking for "best practices" interferes with the normal process of requirements gathering. Don't get me wrong, I'm sure that "best practices" can be useful; it's just that it refers more to general concepts than to specific questions like this one.

Here's an example that I'm familiar with: Nowadays I don't go in to visit my financial advisor. When there is a form to be signed, the secretary fills it in and posts it online for me. I download it, print it, sign it, scan it, and upload it. So when the form gets the uploaded form they can see that I named the form "image1.pdf", which is what the scanning software called it. So in this case, no, they don't need to store the filename from my computer. Other companies, as Junilu says, may have different requirements.

(At one time I did work on a system where we uploaded company logos and used them in our website. I'm sure we had no use for the filename from the client system.)
 
Marshal
Posts: 69780
277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:. . . , no, they don't need to store the filename from my computer. . . .

I do the same; if I download an XYZ.pdf file from some supplier or other, I usually use save as so I can call it ElectricityBill2020-06.pdf or similar, to match my requirements.
 
Sheriff
Posts: 7646
522
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

John Knox wrote:Do we need to save the file name as best practice or it is not needed???


It does depend to most extent on the use case(s), one of which could be if client says: "No, we uploaded file only once", but you have an evidence in database, that filename logo.png was uploaded twice by the same client id, hence got overridden...
idclient_idfilenamecreated_at
14logo.png2020-06-24 14:44:09
27company.jpeg2020-01-10 10:23:02
34logo.png2020-06-24 14:45:09

Thousands of reasons you'd want to store filename, and the same amount of reasons you wouldn't ever need it.
 
Climb the rope! CLIMB THE ROPE! You too tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic