Laravel envoyer storage syncing - php

Ive written a Laravel application where I upload images and pdf files.
Currently In uploading those into a folder within the public directory.
Now I been trying Envoyer.io, where I can easily deploy my projects to the server(s).
The problem here is that each project has its own directory. So everytime all those uploads dissapear.
Ive figgered out that Envoyer does use a symlink for the storage directory in every deployed project.
I can upload the files to the storage directory, but when I return the URL from the files in de storage pth I receive a path like "/var/www/project/app/storage/file.ext" which is the base path. I dont want to return those links in my API cause of security reasons. I there any way I can upload to the storage path and get those uploads with an more friendly URL? Or does anyone have an ither solution?

If you use Laravel Storage feature then you do not need to worry about absolute path. You can even save the files in amazon cloud on completely different machine.
Storage works only with file contents and relative paths instead of absolute paths like PHP File. However you cannot mix the Laravel Storage and PHP File logics easily.
Envoyer must keep the storage folder same within one application. If you need to share it with other projects then upload to Amazon or write your own implementation of the Storage Facade.
More info at http://laravel.com/docs/5.0/filesystem

Related

What is the best approach to save users' images in a server in a secure, private and scalable way?

I'm currently developing a social network using PHP Lumen (Like Laravel but without the frontend part), MySQL and Ionic framework.
What is the best approach to save user images in a way that only the user can get them?
I need to save a user profile picture, but I understand that saving the base64 format of the image in the database is not a good thing as the app scales.
So, my question is: should I save the image as it is but changing the name with some hash, as same as the folder so that only the user could get the right path to it and serve that path to the frontend?
Or, Is it posible to save the image into a folder that just the server can access, and just get the right url to the file using the user session token? Should I encrypt the images? Does it take too much time and processing?
First of all, you should not be using Lumen for building a social networking website. Where Lumen is lightweight, it is missing core utilities that Laravel offers.
Now getting back to your question, you will have to require league/flysystem in your project and use the storage API. You may have to deal with the configurations in Lumen in order to get the filesystem to work properly for you.
Just like Laravel, you should keep the storage folder out of the public folder and symlink the storage's public directory app's public directory. In Laravel, you have the php artisan storage:link command to achieve the results.
Now once the storage is properly configured, public files will be accessible directly when the directory is symlinked, and you can decide on the private files how should they be accessed. Flysystem provides you great flexibility on reading and writing content from/to the disk.

laravel 5.8 how and where change setting that I could upload files in any place on disk

I wanna upload files on server via my application in laravel. I do not want to save them in laravel project folder (some app\public) but in another place for example: C:\my_files. How do that?

Where to upload product images in Laravel?

I am building an e-commerce application using Laravel framework. Which location is most suitable to upload product images, Slider images, Banner images and all dynamically uploaded images in frontend?
storage/app/public
public/img
If am going for storage/app/public location. How can I access those images to website frontend?
I really appreciate any help you can provide.
Store your images in your storage directory.
This is the best place as you can use the Storage facade which makes it easy to store images. https://laravel.com/docs/5.6/filesystem
You can also use the Storage facade the same way you would locally if you were to change your storage destination to a CDN (e.g. Amazon S3). You will just need to change the configuration in config/filesystems.php and the code to store the images will remain the same.
Once you do store the images in the storage directory you can expose them to the frontend by symlink-ing it using php artisan storage:link https://laravel.com/docs/5.6/filesystem#configuration
This will create a symlink from your storage directory in to the public directory.
You can use the helper asset to retrieve the path to the image. https://laravel.com/docs/5.6/helpers#method-asset
--
There are lots of examples on how to store files in the storage directory:
https://quickadminpanel.com/blog/file-upload-in-laravel-the-ultimate-guide/
https://scotch.io/tutorials/understanding-and-working-with-files-in-laravel
How to save uploaded image to Storage in laravel?
use
public/img
then locate it in the front end with asset function
{{ asset('name_of_file') }}

How to manipulate cloud server files using Laravel?

We have developed our application in Laravel and now we are planning to transfer it to Amazon server where we have to separate our application logic with file storage. Basically, we want to move our whole application storage to a cloud server(Amazon S3) and application logic to Amazon EC2 server.
In our system, we manipulate (resize images, merge images, make thumbnails from videos, etc) many storage files locally. We will not be going to store any files on the application server once we migrate to Amazon server. So, our concern is how we can manipulate cloud server files?
Earlier all files are present on the application server so file manipulation was easy to process but after migrating whole storage to cloud server how we can manipulate files that are on the cloud server with manipulation logic resides on the application server?
Any Response will be helpful
Thanks in advance...
To manipulate S3 file, I think first we need to download the file locally. Once, we have file locally we can apply any operation on that particular file. We can delete the local file later.
Here are the documents to directly upload from or download to a local file using the Amazon S3.
https://aws.amazon.com/blogs/developer/transferring-files-to-and-from-amazon-s3/
https://docs.aws.amazon.com/aws-sdk-php/v3/guide/
Thanks

Saved images in Heroku app are not being displayed?

I am new to web development and I have just deployed my site using Heroku. I am using Laravel as the framework and Postgres as the database.
In my site, I have a feature of storing images in my public/images folder. If I saved the images and changed the file permissions before deploying it on Heroku then the images are being displayed. However, if the images are uploaded directly through Heroku, the images won't be displayed.
I am guessing this is caused by file permissions. Maybe because the images that are being uploaded in the public/images folder in Heroku is not inheriting the permission of the folder?
The file system on Heroku is not persistent. You can't save files on the web server file system, and expect those files to be available for subsequent HTTP requests.
You need to use another persistence store, like storing those files on AWS S3 or in your database. There are also probably other addons that would allow you to save files simply enough.
Ref: https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem
Here's an example of saving and displaying images from a Postgresql database: Upload/Download file in POSTGRESQL database with PHP

Categories