I have tried to look for answers for my question but haven't found anything conclusive.
I have a site which, among other things, stores member pictures & thumbnails. They are in separate directories, and within each directory are a cascade of folder names based on properties of the image. This is to prevent thousands of images being in one directory for performance reasons.
for example, a typical image has a URL like:
www.mysite.com/thumbs/100x75/04/18/s3hf9sj_939swzl.jpg
The file location and name are stored in a mysql database so they can be dynamically displayed.
How would a CDN be implemented for my images? Can I recursively select all the images in a directory to be uploaded to the CDN? How often would it update this file information?
And finally, what might happens when the database retrieves a url like the one above? Will the CDN automatically redirect the user to something like this?
www.cdn.mysite.com/thumbs/100x75/04/18/s3hf9sj_939swzl.jpg
Or will I have to design my database differently?
Thank you.
If you choose to migrate to a CDN and not change your URL scheme you would have to make sure requests to www.mysite.com/thumbs/ are routed to your CDN (at www.cdn.mysite.com/thumbs/).
You also need to change your method of saving images to also save a copy to the CDN, or you could create a synchronization script to run periodically, but then you would need to serve your resources from two locations; from your own if the file is not present on the CDN, which would increase the complexity of your setup.
I would make sure I store my resources directly at my CDN at the same time I backup locally and would migrate to a separate domain form my CDN (to allow more concurrent downloads from the user).
Related
Currently, there are gigabytes of images stored on a server that I can access using username#serverip. It is not my server, but I have access to it. Using cd Storage followed by ls -l shows all the files that I would like to be able to be accessible to anyone who visits the actual website. However, all of those files, while they are on the server, are not visible on the website and I was wondering how I could go about doing that. Is there a way to make the files on the server be visible on the website as well?
Are these images? Or just assorted files?
In either case, and without knowing what your actual implementation of the website, generally all webservers have a static resources folder.
In this folder you would put things like your general website images, like favicon, etc.
Put all that stuff in there. Or configure the webserver to use the existing one as such. This is not necessarily best practice though as all of those items would be exposed (potentially) without authentication.
tl;dr
In my node.js application I create pdf documents. What is the best/right way to save them? Right now I use node.js fileserver and shell.js to do it.
I am working on a node.js web application to manage apartments and tenants for learning purpose and on some point I create PDF Documents that I want to save under a path
/documents/building_name/apartment_name/tenant_name/year/example.pfd
Now if the user wants to change the building, apartment or tenant name via an http PUT request I change the database but also the want to change the path.
Well both works but I can't write good tests for these functions.
Now a friend told me that it's a bad practice to save documents on a file server and I better should use BLOB.
On the other side google doesn't really agree on using blobs
So what is the right way to save documents?
Thanks
Amit
You should first define a source of truth. Unless you're legally obliged to keep copies of those files and they are not being accessed very often, I wouldn't even bother storing those at all and just generate them upon request.
If not, keep the DB clean, blobs will make it huge. Put them into cold storage (again assuming they are not being accessed too frequently) without those paths. If the paths are reliant on often changing information, that can't be performant for neither the file server nor your system.
Instead store a revision number in your DB that the file can be found under and limit the path structure to information that rarely change.
Like {building}/{apartment}/{tenant}_{revision}.pfd
That - depending on your backup structure - will allow you to time-travel if necessary and doesn't force a re-index all the time.
Note: I don't know too much about your use case.
I am new to using StackOverflow and I don't know how to properly ask this question also this is my first time using swift and some external database server.
I am creating an ios app using Xcode and I'm attempting to create an inventory to store items (300 - 1000 items) such as milk, eggs, bread etc and will have to store the product image as well as the product details such as weight, price, ingredients etc.
But I have no idea as to what to use I was thinking mysql but after doing some research I've found its best not to use blob. I've already used MySQL for the login page into the app so I assumed it was easier to use mysql for the product database as well.
The idea is the user creates an account, logs in then can view products in my made up store. I wanted to use an external database so I can give the app to friends and they can use it by downloading from the app store when it's finished.
Can you save the bytes of a large file in a database? Yes. Should you? No.
Generally speaking the proper way to handle files in a database is to store the URL of the file, not the file itself.
If the images you're using are available online and you are only need to view them, you only need to save the URL itself. There are libraries that can handle all the downloading and cacheing quite easily once you have the URLs.
If you still need to have the images locally, Save them to disk and store those local File URLs in your database.
I am trying to create a business directory application for my area, I am currently trying to create a sql DB with all of the realivant business information (name, address, opening hours etc). I am then plan to have a physical file directory where all logo images are stored, this directory will be stored somewhere on the server.
When the user starts the applicatoin they will be prompted to download all of the information on business listings (because its for a small community), I will then upload all of the data to the phone using NSURLConnection, the data will be Zlib NSData in the form of XML. I will store all of this data into coredata (which will act as the apps cache).
The next step is to download the directory of images I have stored on the DB.. but I have no idea on the best approach for this and would like some guidance, example code etc.
For instance would it be better to store the images into the sqlDB? I have read this is a bad idea so am trying the approach explained above.
I am still in the process of building the sqlDB but the difficulty I am having is comming up with a way to get the images onto the device and relate them to the correct business using an id field or something simlar.. or is there an easier way to do this?
any help would be appreciated.
Instead of storing the image directly in the DB, you could store the URL to access the image binary instead. This would maintain the relationship with the image without storing the large image data directly in the DB. You could then use the URL retrieved from the DB to download the image on the device and similarly store the path to the downloaded cached image in core data.
I was wondering what the best pattern was to handle the management of images these days when using spring/java and mysql.
I have several options. Some of the
images are just small avatars for
the users. Is it fine to put these
directly into mysql? Or use the file
system?
For the larger images, is file
system pretty much the only option,
and then use mysql to store the
location on the file system?
Where is a good spot to put them on
a linux server? /var/files/images?
Since the files are hidden from the
war deployment directory, what is
the best way to stream them? Use
some kind of a file output stream as
the response body for an http
request?
Also, do I have to develop all of
the file management stuff myself,
like cleaning up unused files and
the like?
What about image security? Some images should not be accessed by everyone. I think I'd need to use a separate url with Spring security checking the current user for this.
I'd appreciate advice on all of these questions. Thanks.
You could use MySQL, and that would have the advantage of centralization and easy cleanup, but IMHO it's a waste of the database's resources if you plan to scale.
For data like images where everything is public, consider something like Amazon S3 which allows you to serve images directly from S3's web servers. If you plan to host everything yourself, just serve from a directory. Just remember to turn directory listings off :)