Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with uploading files #9

Open
melvinchia opened this issue Aug 11, 2020 · 5 comments
Open

Problem with uploading files #9

melvinchia opened this issue Aug 11, 2020 · 5 comments

Comments

@melvinchia
Copy link

melvinchia commented Aug 11, 2020

I'm able to list files and read file contents from Azure File Storage, so I'm pretty sure my connection string is fine.
When I try to write/update a file, I get the following error:

403: Fail: Code: 403 Value: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. details (if any): <?xml version="1.0" encoding="utf-8"?><Error><Code>AuthenticationFailed</Code><Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:33698f74-a01a-005c-7ab3-6f6a14000000 Time:2020-08-11T07:48:02.1835762Z</Message><AuthenticationErrorDetail>The MAC signature found in the HTTP request 'l+Lz9lBDaKq9VZ3k9zoBozQ5j9prREu0VkO9i/LxzxU=' is not the same as any computed signature. Server used following string to sign: 'GET application/x-www-form-urlencoded Tue, 11 Aug 2020 07:48:02 GMT x-ms-request-id:5f324d322c9eb x-ms-version:2016-05-31 /sjlmsib/s3ib/smarthub_sync/new/ restype:directory'.</AuthenticationErrorDetail></Error>.

I'm able to write to the file using the same connection string, but Microsoft API's createFileFromContent function, so I'm sure that my access rights allow me to create and write the destination file.

For reference, this works (it creates the file in the Azure File Share)
$microsoftFileClient->createFileFromContent('share', 'test.csv', $testdata);

And this doesn't work (it produces the error above)
$azureFileAdapterClient->write('test.csv', $testdata);

Any way to fix?

@judgej
Copy link
Member

judgej commented Oct 27, 2020

Sorry, only just spotted this.

I did get a similar error and thought I had fixed it. The error message is a bit of a misnomer, and just means the request is malformed, and it happened after an MS library update. Could you include some PHP and related package versions for me to check please.

Is it a stream you are uploading, orca file from disk?

@melvinchia
Copy link
Author

I tried a file from disk, and just a data array/stream, neither worked.

I'm on PHP 5.6.40, and consilience/flysystem-azure-file-storage is at 0.1.4. league/flysystem is at 1.0.70.

@judgej
Copy link
Member

judgej commented Nov 4, 2020

I'm using a later version of PHP (7.3 and 7.4) and not seeing a problem writing files.

I'm using academe/laravel-azure-file-storage-driver to deliver the config settings from a Laravel filesystem to this package. The setting looks like this:

        'my-uploads-filesystem' => [
            'driver' => 'azure-file-storage', // This driver.

            'storageAccount' => env('AZURE_FILE_STORAGE_ACCOUNT'),
            'storageAccessKey' => env('AZURE_FILE_STORAGE_ACCESS_KEY'),

            // The file share.
            'fileShareName' => env('AZURE_FILE_STORAGE_NAME', 'name-of-azure-file-share'),

            // Optional settings
            'disableRecursiveDelete' => true,
            'driverOptions' => [],

            'root' => env('MY_ROOT', 'uploads'),
        ],

You may not be using Laravel, but those are the assential settings that are mapped to the driver. I'm not sure what could be happening to cause the MAC signature error, other then the authentication details. The access key I am using is a string of mixed case alpha-numeric characters with "==" at the end.

@judgej
Copy link
Member

judgej commented Nov 4, 2020

I get exactly the same error with incorrect authenticarion details just listing files in a directory, if that helps.

@melvinchia
Copy link
Author

I'm unable to use PHP7, due to other dependencies on the project and server..

But since I'm able to list and read the file contents of a test file I put up, it shows that something is working, and something isn't correct? 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants