How to go about storing and accessing of images inside the blog using LAMP stack? - html

I want to create a technical blog using LAMP stack (Laravel Framework). I would like to know what is the best way of storing and accessing images inside a blog content?
There is one way of doing this that I could think of:
(1) Storing the images as a file and then accessing those images using path which is specified as the src attribute of the tag which could be the part of content fetched from the database.

The most correct thing would be to store it in storage. Laravel provides a powerful filesystem abstraction thanks to the wonderful Flysystem PHP package by Frank de Jonge. The Laravel Flysystem integration provides simple to use drivers for working with local filesystems, Amazon S3, and Rackspace Cloud Storage. Even better, it's amazingly simple to switch between these storage options as the API remains the same for each system.
That is, you can store them locally on your LAMP server or you can use an external server for that. Both ways are good, however it depends on your needs.
You have to store the relative path in the database. i.e. /path/to/image.jpg
Then to show these files with the Facade Storage you can show them easily.
If you are using the local driver, this will typically just prepend /storage to the given path and return a relative URL to the file. If you are using the s3 or rackspace driver, the fully qualified remote URL will be returned:
use Illuminate\Support\Facades\Storage;
$url = Storage::url('image.jpg');

Related

How do I integrate wikipedia data to my local mediawiki?

I have set up a local mediawiki instance. It's running fine. Now I want the entire wikipedia locally.
I found this dump : https://dumps.wikimedia.org/enwiki/latest/
Which files do I download?
Once downloaded, how do I set up push the data to mediawiki?
I used : https://github.com/rlewkowicz/docker-mediawiki-stack to set up MediaWiki on my AWS instance.
My end-target is to use the Wikipedia Search API from my AWS instance, instead of the publicly available endpoints.
The Wikipedia dump is huge and your installation will probably crash. If you want to try anyway, mwdumper is probably your best bet for the xml files. It's not very well maintained. I don't think there is any out-of-the box solution to automatically push updates.

Openshift - Redirect requests only on specific gear

I'm using HAProxy and I have more than one gear, but I have to use file system.
The problem is Gears don't share file system so I wonder if I have to setup HAProxy in way to let me redirect specific requests to a specific gear(the one that contains cronjobs).
Must I use HAProxy or have I alternatives?
Edit
Share the file system across gears would be great but not is completely necessary. My users don't need access. I just want the posibility to write files in the same gear. My using an specific URL o any other trick.
For example, it would be enough an specific URL go always to an specific(and why not the same) gear.
You should use something like amazon s3 to store your files, then they will be accessible to all of the gears in your scaled application.You would need to use an amazon s3 access library that is available for your language. If you are using Ruby on Rails, I would suggest using Paperclip.
I don't believe that you will be able to modify the haproxy configuration enough to always send a specific user to a specific gear within your application, and that also is a really bad programming practice to get in the habit of...

File storing on Ruby/Rake/Grape server

I am trying to find out a solution for the solution I want to implement.
I would like to store "avatar"s on my server for my users.
But I would like the images to be accessible only if you have a valid session token and a valid user_id.
I would rather not store the images in the database if possible.
I am using Ruby, with Rake, ActiveRecord, and Grape. It is an API not a website.
I use mySQL as a database.
The server is an Apache using passenger to interpretate the ruby.
Do you know if it is possible to serve an image, like apache would do it when you access one but beeing able to control the access to this image using my access tokens?
I suggest to use paperclip to store your images it has option for uri obfuscation: https://github.com/thoughtbot/paperclip#uri-obfuscation
I use it in combination with grape as well and it works fine for me.

Is it bad to store images as Data URIs in a database BLOB?

I'm creating a mobile app that views articles. These articles are just simple html with a couple of images each. I am currently storing everything in a database. Later, I will need to save the articles locally to the device in an easy format. For this reason, I have opted to store the Base64 images within the database, using a Data URI Scheme (look here for info http://en.wikipedia.org/wiki/Data_URI_scheme).
My question is: is it okay to store this much data in one database entry? I have a table that is ONLY for these large records, with article meta data tables that point to these. Would it be better if I used TEXT fields, rather than BLOBs?
If it helps, I am using MySQL with the InnoDB engine.
Avoiding using the db to store images is a good practice, keeping the images in the db not only slows down your db performance it also increases it size and backups, if you are using cloud service then there is also the cost issue.
Use S3 or Azure for this purpose and have only the url of the images in your db.Files may be uploaded directly to to the storage service reducing load on your db server. The only thing left to do is for your mobile application to connect both this services(db and the Images service),i found this web tool to manage my mobile app db because it connect to my Images cloud service which is Azure but i think they also support Amazon S3.
Another option would be to store images in something like:
Amazon S3
and then just have a field in your database that stored the url for each image.
As long as you dont have a DB as big as facebook or similar it should be fine.
It is best to store just the path to the image and the image themselves in a folder.
hope that helps
You could also look into Azure Blob Storage. I've been using it and it's working very well.

Dealing with mass images, some small - some large, in spring/java application using mysql

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 :)