Error in setting headers
See original GitHub issueHey,
I am getting the following error when the request goes for S3.
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Invalid according to Policy: Policy Condition failed: ["starts-with", "$Content-Length", ""]</Message>
<RequestId>12F4B56163EF2740</RequestId>
<HostId>SHiiZPupIS+0JxFHt2Jj2ksgis/X6cJzUIKeriLUOqtjKRBCZ0jx09bN9HUgLa7F</HostId>
</Error>
The code that I am using is as follows.
div(s3-upload bucket="'BUCKET" dynamic-name="field" ng-model="field.value" s3-upload-options="{getOptionsUri: '/s3options', folder: 'images/'}")
On the server I am using a library to generate the policy. Policy Generator
app.get('/s3options', function(req, res) {
var p = policy({
secret: 'FhfMGu32+hqnwtIpgT4WSNlE3ieyN9Vn8bAr+k',
length: 10 * 1024 * 1024,
bucket: 'tfiapp',
key: 'AKIAIDFSRY33SEKOFMBA',
expires: new Date(Date.now() + 60000),
acl: 'public-read',
type: ""
});
p.key = "AKIAIDFSRY33SEKOFMBA"; console.log("Key:" + p.key);
res.send(p);
});
Issue Analytics
- State:
- Created 9 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Cannot set headers after they are sent to the client in JS
The "Cannot set headers after they are sent to the client" error occurs when the server in an express.js application sends more than...
Read more >Understanding Node Error [ERR_HTTP_HEADERS_SENT]
This post describes why the Node Error [ERR_HTTP_HEADERS_SENT] cannot set headers after they are sent.
Read more >Cannot set headers after they are sent to the client | End Your If
Why am I receiving the error message can't set headers after they are sent to the client Nodejs? · Calling the request handler...
Read more >Resolving HTTP Cannot set headers after they are sent ... - Fjolt
This is quite a confusing error if you aren't familiar with HTTP headers. This error arises when you send more than 1 responses...
Read more >How to set header Content-Type in error rule - Forums - IBM
I want to set few headers in error-rule. All of the headers are getting set but the headerContent-Type is not getting set. Can...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@khakiout That should work. Or you could remove the Content-Length condition from the policy generated by node-s3-policy.
@jseppi so the solution should be that
ng-s3upload
must add a Content-Length property to its FormData? Something likefd.append('Content-Length', length)
?