question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error in setting headers

See original GitHub issue

Hey,

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:closed
  • Created 9 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jseppicommented, Jul 30, 2014

@khakiout That should work. Or you could remove the Content-Length condition from the policy generated by node-s3-policy.

1reaction
khakioutcommented, Jul 30, 2014

@jseppi so the solution should be that ng-s3upload must add a Content-Length property to its FormData? Something like fd.append('Content-Length', length)?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found