Laravel Vapor upload to DO Spaces - laravel

I want to use Laravel Vapor on my application. There's documentation on how to upload files to S3 using Vapor but none using other cloud providers. Is it possible to upload files to Digital Ocean's Spaces using vapor? If so does anyone have some sample code I could look at

Here's a sample configuration for some "attachments" filesystem on DigitalOcean (its considered an "S3" service as well). I used it in a raw Laravel project but I expect Vapor to offer a very similar configuration file.
So in essence it should work out of the box if you give it the correct credentials:
// config/filesystems.php
'attachments' => [
'driver' => env('ATTACHMENTS_DRIVER', 's3'),
'root' => 'attachments/',
'key' => env('DO_SPACES_KEY'),
'secret' => env('DO_SPACES_SECRET'),
'endpoint' => env('DO_SPACES_ENDPOINT'),
'region' => env('DO_SPACES_REGION'),
'bucket' => env('DO_SPACES_BUCKET'),
],
I added the DO_SPACES_xxx variables myself, you define them in your .env file, they should look similar to this:
DO_SPACES_KEY=5SOME4KEY3KRANDOMG
DO_SPACES_SECRET=12FABCI6D1MIz+Xep+321BC3MHcz+ABCO21
DO_SPACES_ENDPOINT=https://nyc3.digitaloceanspaces.com
# Region is empty in my configuration, not sure if you need it.
DO_SPACES_REGION=
DO_SPACES_BUCKET=yourbucketname

Related

Laravel 8 - Find image url

I am using Laravel Framework 8.68.0.
I am having the following configuration in my filesystems.php:
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
'public_collectible_img' => [
'driver' => 'local',
'root' => storage_path('app/public/collectibles_img'),
'url' => env('APP_URL').'/collectible/image',
'visibility' => 'public',
],
The following link works:
http://localhost/myProject/public/storage/collectibles_img/0_test.jpg
The following link does not work:
http://localhost/myProject/public/collectible/image/0_test.jpg
All my images are in the following folder:
Any suggestion why my second link does not work?
I appreciate your replies!
The filesystems.php only affects Laravel's internal filesystem management (e.g. moving a file from within Laravel, saving an uploaded file, etc.), not the actual HTTP server which is what serves static files such as images. If you want to have a custom URL, you can either modify your web server's configuration (e.g. .htaccess), or create a Laravel route and controller to serve files from within Laravel. The latter approach will require that you map the requests to files yourself, and each request would have the overhead of loading PHP.
Alternatively, you could create a symlink from public/storage/collectibles_img to public/collectible/image (you would need to create the collectible folder first, then set up collectible/image as a symlink to public/storage/collectibles_img).

SOLVED - Laravel 5.8 Save file and image in another project and retrieve it

i have two project in laravel 5.8.
First in sub1.domain.com
Second in sub2.domain.com
With sub2 i save images and files.
I need to view the image and files from sub2 and sub1.
Where is the best directory store for sharing the image and files ?
I have a shared hosting.
Thanks.
UPDATE - SOLVED
I have changed my filestystem config in this mode:
'public' => [
'driver' => 'local',
// 'root' => public_path() . '/uploads',
'root' => '/home/xxx/www',
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
Now the file is stored in "public_html" of my "website.com" on my hosting for every subdomain.
Thanks everybody.
The docs state
The public disk is intended for files that are going to be publicly
accessible. By default, the public disk uses the local driver and
stores these files in storage/app/public. To make them accessible from
the web, you should create a symbolic link from public/storage to
storage/app/public
Assuming all your images & files will be publicly accessible, follow those instructions.
Then, instead of using asset('storage/file.txt') to print out the publicly accessible url, you could use a value from your .env file to get the path, which would be something like "https://sub2.domain.com/images/" and then just append your file name.
Or write a custom helper method that allows you to specify the subdomain, something like custom_asset('storage/file.txt', 'sub2')
you can upload in public folder as symbolic link is hard hard to make cpanel
modify ur
filesystems.php
in
'public' => [
'driver' => 'local',
'root' => public_path('app/public/uploads'),
'url' => env('APP_URL').'/uploads',
'visibility' => 'public',
],
in above linke
ur upload path will be
public/uploads
and
\Storage::url('example.png') to get full image url

ckfinder is not able to access the remote server files

I'm using CKFinder in my web app (based Laravel), in order to navigate and upload files to an nginx storage server.
I manage to do so when developing on localhost, so the connectivity between the client app and the storage server was using FTP.
After deploying the app into appEngine server, I'm getting the error: "It was not possible to complete the request due to file system permission restrictions".
Nothing have changed in the depolyed applocation, the code is exactly the same as in the localhost. except for the fact that the appEngine runs the app over https instead of http.
what might be the problem for this issus?
here are some of my configurations for ckfinder:
config.php:
$config['backends'][] = array(
'name' => 'my_conntection',
'adapter' => 'ftp',
'host' => 'hostnname',
'username' => 'username',
'password' => 'password',
'root' => '/upload',
'chmodFiles' => 0644,
'chmodFolders' => 0755,
'baseUrl' => 'https://hostname/upload',
'passive' => 'false',
);
What should I also do? Am I missing something?
Is there any alternatives for this annoying ckfinder?

Laravel 5.4 producing public/uploads/avatar folder

I have a fundraising platform built with Laravel 5.4. I've been successful in removing the public from the URL and hiding both the .env and composer.json files from view, but I can't upload an avatar to the upload/avatar folder from the admin or user account because Laravel produces a public/uploads/avatar folder and uploads the avatar into it instead of into the upload/avatar folder where it needs to go.
I have tried updating routes and usercontroller but to no avail. I'm not sure where to look now.
Can someone help me out with telling me where I go to change the code so Laravel no longer produces a public/uploads/avatar folder when I upload an avatar so the avatar goes into the upload/avatar folder instead?
Thanks.
In Filesystems.php
Change this:
'public' => [
'driver' => 'local',
'root' => public_path(),
],
To this:
'public' => [
'driver' => 'local',
'root' => '/',
],

Laravel OpenShift Deployment Issue in database migrations

I am trying to deploy a Laravel 4.2 application on RedHat OpenShift.
I have successfully transferred the code from GitHub but I am stuck at the database integration.
How do I run the migrations?
I have created a new mysql_openshift database connection with
OpenShift credentials and updated the same.
I have a migration file in the migrations folder.
But on running the php artisan migrate i get the following error:
http://i.stack.imgur.com/nQbam.png
Please help!
The Laravel 4.2 QuickStart was updated 2 days ago. The QuickStart now automatically runs php artisan migrate when you deploy changes to OpenShift. I definitely recommend switching over to using the QuickStart or updating to the latest version.
Anyways, the short answer to the problem you're seeing: your database is not configured properly in Laravel. See lines 60-70 of app/config/database.php in the Laravel 4.2 QuickStart for a reference on configuring the host/port connection info.
Your openshift db parameters are not set correctly.
Look at your config/database.php you will see how the setting in .env are used. Like before we try to get environmental variables from Openshift. The function env('DB_HOST', 'default') will take either DB_HOST from .env or use the default value in the second parameter. Since .env is excluded from version control, Laravel will take the Openshift-specific settings instead.
So put the following code in your config/app.php :
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', getenv('OPENSHIFT_MYSQL_DB_HOST')),
'database' => env('DB_DATABASE', getenv('OPENSHIFT_APP_NAME')),
'username' => env('DB_USERNAME', getenv('OPENSHIFT_MYSQL_DB_USERNAME')),
'password' => env('DB_PASSWORD', getenv('OPENSHIFT_MYSQL_DB_PASSWORD')),
'port' => env('DB_PORT', getenv('OPENSHIFT_MYSQL_DB_PORT')),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,],

Resources