Code Monkey home page Code Monkey logo

Comments (6)

tpyo avatar tpyo commented on July 4, 2024

Are you only getting signature errors when using UTF-8 headers? Do UTF-8 object names still work for you?

from amazon-s3-php-class.

smartinec avatar smartinec commented on July 4, 2024

I'm not sure exactly what you mean by UTF-8 object names. The 'keyword' header is always encoded as UTF-8 as is the actual content stored in S3 (search engine result page). Here is an example page we are trying to store that had a failure:

http://www.google.com.tw/search?q=%E5%AC%8C%E7%94%9F%E6%95%A3%E5%85%89%E9%9A%B1%E5%BD%A2%E7%9C%BC%E9%8F%A1&gl=TW&hl=zh_TW

We set Content-Type to what is returned by the engine. In this case "text/html; charset=UTF-8". We also set Content-Encoding to "gzip" since we use "gzencode()" on the response.

from amazon-s3-php-class.

Slach avatar Slach commented on July 4, 2024

code for reproduce

S3::setAuth('XXX', 'XXX');
S3::setExceptions(true);


$put = S3::putObject(
    S3::inputFile('1.txt'),
    'your_bucket',
    '1.txt',
    S3::ACL_PUBLIC_READ,
    array( // Custom meta headers
    ),
    array( // Custom $requestHeaders
      "Cache-Control" => "max-age=315360000",
      "Expires" => gmdate("D, d M Y H:i:s T", strtotime("+5 years")),
      "Content-type" => "text/plain",
    )
)
var_dump($put);

Expected result
bool(true)

Actual result
Fatal error: Uncaught exception 'S3Exception' with message 'S3::putObject(): [SignatureDoesNotMatch] The request signature we calculated does not match the signa
ture you provided. Check your key and signing method.' in S3.class.php:554

HTML Request

PUT /uploads/1.txt HTTP/1.1
User-Agent: S3/php
Accept: /
x-amz-acl: public-read
Host: lingualeo_cdn.s3.amazonaws.com
Date: Sat, 16 Jun 2012 15:21:58 GMT
Content-MD5: aVSG6u6vFHNzw7+fh5KVCA==
Content-Type: text/plain
Cache-Control: max-age=315360000
Expires: Fri, 16 Jun 2017 15:21:58 GMT
Content-type: text/plain
Authorization: AWS AKIAJQPD6HCEUK55UXDQ:iac8pbUCyvYD2XhrnBwPEsb9K+o=
Content-Length: 8
Expect: 100-continue

HTML Response

HTTP/1.1 403 Forbidden
x-amz-request-id: 12631B4F2C527789
x-amz-id-2: pWcELTdRMhMpwLmzJY6aWppXRnqOWVJUJxVWB4ewOI6lDdmdQ9Kit/RgYiD1hscG
Content-Type: application/xml
Transfer-Encoding: chunked
Date: Sat, 16 Jun 2012 15:22:10 GMT
nnCoection: close
Server: AmazonS3

41b

SignatureDoesNotMatchThe request signature we calculated does not match the signature you provided. Check your key and signing method.50 55 54 0a 61 56 53 47 36 75 36 76 46 48 4e 7a 77 37 2b 66 68 35 4b 56 43 41 3d 3d 0a 74 65 78 74 2f 70 6c 61 69 6e 2c 74 65 78 74 2f 70 6c 61 69 6e 0a 53 61 74 2c 20 31 36 20 4a 75 6e 20 32 30 31 32 20 31 35 3a 32 31 3a 35 38 20 47 4d 54 0a 78 2d 61 6d 7a 2d 61 63 6c 3a 70 75 62 6c 69 63 2d 72 65 61 64 0a 2f 6c 69 6e 67 75 61 6c 65 6f 5f 63 64 6e 2f 75 70 6c 6f 61 64 73 2f 31 2e 74 78 7412631B4F2C527789pWcELTdRMhMpwLmzJY6aWppXRnqOWVJUJxVWB4ewOI6lDdmdQ9Kit/RgYiD1hscGiac8pbUCyvYD2XhrnBwPEsb9K+o=PUT
aVSG6u6vFHNzw7+fh5KVCA==
text/plain,text/plain
Sat, 16 Jun 2012 15:21:58 GMT
x-amz-acl:public-read
/lingualeo_cdn/uploads/1.txtAKIAJQPD6HCEUK55UXDQ
0

from amazon-s3-php-class.

tpyo avatar tpyo commented on July 4, 2024

Would you be able to try this patch? It seems like it is likely related to the meta header order.

codemedic@5e2d6f2

from amazon-s3-php-class.

Slach avatar Slach commented on July 4, 2024

thanks! patch work fine...
may be you merged this patch to main project repository?

from amazon-s3-php-class.

tpyo avatar tpyo commented on July 4, 2024

The patch uses a lambda style function, it should ideally be a separate function for older PHP versions.

But I'm busy implementing it now, should push changes later today.

from amazon-s3-php-class.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.