I am trying to upload file to Amazon S3, but still got an error.
local.ERROR: The PutObject operation requires non-empty parameter: Bucket {"exception":"[object] (InvalidArgumentException(code: 0): The PutObject operation requires non-empty parameter: Bucket at /usr/share/nginx/html/PaymentCloud-API/vendor/aws/aws-sdk-php/src/InputValidationMiddleware.php:64)
I looked at all posts related to this in stackoverflow and github.
This is the way I used to upload file.
Storage::disk('s3')->put('filename', 'content')
I checked content and I received it successfully.
I checked s3 configuration in .env and filesystems.php, but they are all fine.
I solved this issue!!!
It took a lot of time to fix it, but finally the solution was really simple.
It was just because of the .env cache. So I just cleared the cache and restart my server.
Now, it works.
php artisan config:clear
php artisan cache:clear
Related
Please excuse me, as there are already many questions on the same topic.
First some background: I started working on a Laravel 9 web application few months ago, created AWS S3 buckets and an IAM user with full access to AmazonS3, and used the user's access credentials in .env file. And I was able to upload files to the specified bucket, and was able to access the uploaded files in my web application.
Last week, I worked on SMTP setup for sending emails and made some changes to the .env file (though I am sure that I did not change the AWS settings). Now I notice that the uploading files to the AWS S3 bucket is failing with the message:
exception: "League\\Flysystem\\UnableToWriteFile"
file:"/var/www/vhosts/silkweb.ca/vendor/league/flysystem/src/UnableToWriteFile.php"
line: 24
message: "Unable to write file at location: user/profile/3/P2jFdBHTE49mxym6jxa4LHTAPvV0qDiFZ9SsYtZt.png. Error executing \"PutObject\"
I use the following commands to put the file in the AWS S3 bucket:
$filepath = "/user/profile/".$user_id;
$upload_path = Storage::disk('s3')->put($filepath, $request->file('file'));
I even created a new IAM user and used that user's credentials in my .env file, but still no luck. My current .env settings for AWS are as follows
AWS_ACCESS_KEY_ID=AKI***************DAY
AWS_SECRET_ACCESS_KEY=jotz*************************ru
AWS_DEFAULT_REGION=us-east-2
AWS_BUCKET=silkweb
AWS_URL=silkweb.s3.us-east-2.amazonaws.com
AWS_ENDPOINT=http://silkweb-s3.us-east-2.amazonaws.com
AWS_USE_PATH_STYLE_ENDPOINT=false
I have used php artisan clear:cache and php artisan config:clear several times.
Any idea, why I am not able to create a file in the AWS S3 bucket?
After I commented the AWS_URL and AWS_ENDPOINT, file upload started working. The following are the working settings
AWS_ACCESS_KEY_ID=AKI***********DG
AWS_SECRET_ACCESS_KEY=l36***************0C
AWS_DEFAULT_REGION=us-east-2
AWS_BUCKET=silkweb
AWS_USE_PATH_STYLE_ENDPOINT=false
AWS_S3_SILKWEB_URL="https://silkweb.s3.us-east-2.amazonaws.com/"
**#AWS_URL=silkweb.s3.us-east-2.amazonaws.com**
**#AWS_ENDPOINT=http://silkweb-s3.us-east-2.amazonaws.com**
i uploaded my laravel 8 project to my subdomain and i received this error
file_put_contents(E:\Projects\API\api-worforce\storage\framework/sessions/UkfntojT5Qzf99w9TR6Jvxs6iOBKlJ3TvLB6clTF): failed to open stream: No such file or directory
its still using local directory
Some of Laravel files are so-called cached. Therefore, the cache must be removed to fix this error as well.
How to fix the problem(two methods):
Method 1: Just go to the following path of your project in Laravel host and rename the config.php file to config_old.php or delete this file completely:
bootstrap / cache
Method 2: If the first method is not effective in solving the problem, run the following command this time:
php artisan config:clear
php artisan cache:clear
php artisan congif:cache
My problem is that i tried to upload my project to the server (using filezilla uploaded the whole thing) and encountered this error:
"The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths."
Searching on google, people says its a key problem on .env file. But that wasn't my case. the Key is there, I even use php artisan key:generate. it's like the server isn't reading the .env file
I tried config:cache and uploaded the "config.php" that was generated inside the cache folder and now the app cant finds the "views" because the paths are not the server paths but the local ones.
I tried everything, even uploading a fresh laravel installation and again: "The only supported ciphers are AES-128-CBC.."
Also tried config:cache on the server using the routes:
Route::get('/config-cache', function() { $exitCode = Artisan::call('config:cache'); return 'done.'; });
But i get this error: "putenv() has been disabled for security reasons"
I don't really know how to proceed..
You are getting this error because you have to generate key
try
php artisan key:generate
Or generate locally then replace it with .env
APP_KEY=YourGeneratedKey
I uploaded all laravel project on server, its working fine on local but getting error on server, even database configuration and key is configured in env. file. even i renamed .env.example file as .env too but got same error.
Error is
"Whoops, looks like something went wrong."
my error log is here:
[2017-11-06 15:19:07] local.ERROR: exception 'RuntimeException' with
message 'The only supported ciphers are AES-128-CBC and AES-256-CBC
with the correct key lengths.' in
/home/rndspot5/public_html/dev/lea/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php:43
Judging from your error, you need to run php artisan key:generate this will update your key of which in turn will rectify your error.
You will need to either SSH into your public_html folder if you have host permission to do so. Alternatively, you can ask your host provider to either:
Grant you SSH access
Perform this action for you.
You can then run: php artisan config:clear once the new key has been generated.
If you are on shared hosting you can use these steps
Open your .env file, copy APP_KEY to somewhere else as a backup
Run php artisan key:generate from console
Copy the new APP_KEY and upload it to the .env file on your (shared) server
Move the old key back to development
I resolved this issue, by adding web app url in .env and Config/App.php and now its working :) thanks all of you for sharing such a value able knowledge that will help me, may be later.
I was playing with Laravel by refreshing the page 10 times in a second and did this many times continuously. I got the below error
The only supported ciphers are AES-128-CBC and AES-256-CBC with the
correct key lengths.
This is a test case which can occur anytime by end user also. Is there any way to fix it?
I already have key in my env file. This issue occurs only when i refresh the page again and again,
I already checked the answer but could not help
As posted by one of the users at this issue at GitHub,
Under a heavy load of requests, two async requests are made, and during the second request the .env file is locked, so you receive the error only for that request.
To solve this, you can create a cache using below command, which will bypass your .env file on further requests.
php artisan config:cache
Run following command from application folder:
$ php artisan key:generate
First make the key if doesn't exists by running following command.
php artisan key:generate
Next clear your config cache.
php artisan config:clear
Propably application cached your config without app-key.