I'm on a Laravel 5.4 project, and in my composer.json file I'm using the following dependencies:
"league/flysystem-aws-s3-v3": "~1.0",
"aws/aws-sdk-php-laravel": "3.*",
When I try running the below, everything works fine:
Storage::disk('s3')->delete('exports/a_few_subdirectories/file.xls');
However, when I try running this line of code in an Artisan command, I get the below error:
Storage::disk('s3')->deleteDirectory('exports');
Here is the error message I receive:
Aws\S3\Exception\S3Exception Error executing "DeleteObjects" on "https://mybucket.s3.us-west-2.amazonaws.com/?delete"; AWS HTTP error: Client error: `POST https://mybucket.s3.us-west-2.amazonaws.com/?delete` resulted in a `400 Bad Request` response:
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>MalformedXML</Code><Message>The XML you provided was not well-formed (truncated...)
MalformedXML (client): The XML you provided was not well-formed or did not validate against our published schema - <?xml version="1.0" encoding="UTF-8"?>
After googling around, I found a couple of users who had this same error for significantly different reasons. One user said they had hit a 1,000 key limit, and another user said they were missing a required parameter in their post request, but these users were both using Ruby and not Laravel. Since I'm using these composer packages, I'm assuming the packages are working correctly, and it also seems like everything on S3 is set up correctly (permissions and security settings, for instance). Another fun fact is that I can successfully use deleteDirectory with the local driver instead of the S3 driver, so deleteDirectory is working in that instance.
Any ideas as to what might be amiss? I'd rather delete the directory than loop through files and delete them one by one on S3. Thanks in advance.
Related
I uploaded files from SavsoftQuiz_v5.0 to my web server and configured all the necessary files step by step. Tried running the site on the web and it keeps producing an error:
HTTP ERROR 500 - This Page isn't working.
The error logs generated this file
ERROR - 2020-04-21 22:45:31 --> Severity: error --> Exception:
Session: Configured save path '/var/lib/php/session' is not a
directory, doesn't exist or cannot be created.
/var/www/vhosts/africansurveyors.co.zw/httpdocs/Eduline/system/libraries/Session/drivers/Session_files_driver.php
138
HOW DO I FIX THE PROBLEM?
shan is correct, you need to configure your php session to allow write access or to point to a folder you control that actually exists.
Reading a similar usage from https://codeclimate.com/github/bcit-ci/CodeIgniter/system/libraries/Session/drivers/Session_files_driver.php/source [Line112]
it looks like you can set "session.save_path" value from php.ini. Set this to something you control, maybe it supports relative paths, go find out!
You may find you have other folders incorrectly set or defaults assigned, like your temp folder. Don't be afraid to get familiar with php.ini if you plan to stick with php things, but backup before you make changes!
Here is what I did:
I created the front end using Angular 2, and created the backend code using Spring boot. Then in my front end code, I hard code my api address using EC2 address (which is in front end), and hard code my front end address (the S3 address) in Filter class in Spring boot to get rid the CORS issue.
Then in my front end I run ng build --prod to get the deploy static files, in my backend I run mvn package to get the jar file. Upload the jar file to EC2 instance, it starts successfully for the backend part.
Now upload all the static files into S3 storage, and run the S3 domain, I got following error:
Failed to load ec2-35-182-225-61.ca-central-1.compute.amazonaws.com:8080/api/refresh: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
Is it have any tutorial that link front end and backend using S3 and EC2?
Edit:
After I added the CORS on S3 part by trichetriche's answer, I got new error
main.e4936af900574d09c368.bundle.js:1 ERROR DOMException: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL
at http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/polyfills.b3f1cff0521ef8205be4.bundle.js:1:56874
at XMLHttpRequest.o.(anonymous function) [as open] (http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/polyfills.b3f1cff0521ef8205be4.bundle.js:1:20687)
at t._subscribe (http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/main.e4936af900574d09c368.bundle.js:1:424047)
at t._trySubscribe (http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/main.e4936af900574d09c368.bundle.js:1:7030)
at t.subscribe (http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/main.e4936af900574d09c368.bundle.js:1:6859)
at e.a (http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/main.e4936af900574d09c368.bundle.js:1:745892)
at e._innerSub (http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/main.e4936af900574d09c368.bundle.js:1:748287)
at e._tryNext (http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/main.e4936af900574d09c368.bundle.js:1:748211)
at e._next (http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/main.e4936af900574d09c368.bundle.js:1:748034)
at e.next (http://cloud.eatr.com.s3-website.ca-central-1.amazonaws.com/main.e4936af900574d09c368.bundle.js:1:9365)
Did you set up the CORS of your S3 ?
In your S3 configuration, you should add this :
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
This is under The Permissions tab, in CORS Configuration
(And once you're done testng, remember to set the origin to your domain)
I am facing below issue in my entire installations of M2.
[InvalidArgumentException]
There are no commands defined in the "setup" namespace.
weird thing is I installed fresh Xampp and set up new M2 instance, then also same issue persists. It started coming suddenly and I have tried all available solutions like setting permissions to folders and trying -vvv option and list command to find exact issue.
till now no success. My whole day wasted in debugging this only and now I am running out of thoughts.
If anyone have ideas?
I am using PHP 5.6 and Magento EE 2.1.7
Try Following Solution :
Solution 1 :Please mention setup_version in your module.xml file. Your module.xml file looks like:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Vendor_Module" setup_version="1.0.0"/>
</config>
Solution 2 : You need to give full permission to both var and pub folders recursively.
sudo chmod -R 777 var pub
if above solution not work then try following link
https://magento.stackexchange.com/questions/103774/magento-2-there-are-no-commands-defined-in-the-setup-namespace-on-windows
The reason for this error can be seen in the command output: php -f bin/magento.
This will work for most errors like There are no commands defined in the "..." namespace..
A fairly common cause is an error in xml files e.g. VendorName/ModuleName/etc/config.xml.
I have a new computer and I'm trying to set up my AWS CLI environment so that I can run a management console I've created.
This is the code I'm running:
def create_bucket(bucket_args)
AWS_S3 = Aws::S3::Client.new(signature_version: 'v4')
AWS_S3.create_bucket(bucket_args)
end
Which raises this error:
Aws::S3::Errors::SignatureDoesNotMatch - The request signature we calculated does not match the signature you provided. Check your key and signing method.:
This was working properly on my other computer, which I no longer have access to. I remember debugging this same error on the other computer, and I thought I had resolved it by adding signature_version = s3v4 to my ~/.aws/config file. But this fix is not working on my new computer, and I'm not sure why.
To give some more context: I am using aws-sdk (2.5.5) and these aws cli specs: aws-cli/1.11.2 Python/2.7.12 Linux/4.4.0-38-generic botocore/1.4.60
In this case the issue was that my aws credentials (in ~/.aws/credentials) - specifically my secret token - were invalid.
The original had a slash in it:
xx/xxxxxxxxxxxxxxxxxxxxxxxxxx
which I didn't notice at first, so when I double clicked the token to select the word, it didn't include the first three characters. I then pasted this into the terminal when running aws configure.
To fix this, I found the correct, original secret acceess token and set the correct value in ~/.aws/credentials.
I think the below should work based on what I've read but I get an error. I'm surely not expected hard code my password in .netrc. I've ran heroku:set JSPM_GITHUB_AUTH_TOKEN obvs! I've not base64 encoded the token, maybe thats the problem
heroku run jspm config registries.github.auth $JSPM_GITHUB_AUTH_TOKEN
$ heroku run jspm init
Running jspm init on test... up, run.7011
ok Verified package.json at package.json
Verified config file at frontend/system.config.js
Looking up loader files...
warn Error on download for github:systemjs/systemjs
Unauthorized response for GitHub API.
Use jspm registry config github to reconfigure the credentials, or update them in your ~/.netrc file.
err TypeError: Cannot read property 'toString' of undefined
at Object.exports.log (/app/node_modules/jspm/lib/ui.js:99:27)
at /app/node_modules/jspm/lib/core.js:361:8
at process._tickCallback (node.js:377:9)