0

When I am uploading a file to the Azure FILE Storage I am getting the following error:

in 
E:\WAMP\www\myweb\_protected\vendor\microsoft\windowsazure\WindowsAzure\Common\Internal\Http\Url.php at line 74 – WindowsAzure\Common\Internal\Validate::isTrue(false, 'Provided URL is invalid.')

E:\WAMP\www\allure\_protected\vendor\microsoft\windowsazure\WindowsAzure\Common\Internal\RestProxy.php at line 122 – WindowsAzure\Common\Internal\Http\Url::__construct('https://cG9rYXJuYXZpb282mGQ=.blo...')

The settings that I have in my config file is:

'filesystem' => [
            'class' => 'creocoder\flysystem\AzureFilesystem',
            'accountName' => 'azure-accname',
            'accountKey' => 'some-long-key-A==',
            'container' => 'azure-container',
],

and finally, the code I am calling to save the file is:

if($file = \yii\web\UploadedFile::getInstance($this, 'attachment'))
{
    $stream = fopen($file->tempName, 'r+');
    Yii::$app->filesystem->writeStream($file->name, $stream);
}

Some additional information that might be helpful

  1. running on yii2 advanced framework
  2. webserver: IIS 8.5 on Windows 2012
  3. PHP 5.4.5
  4. composer used for installation
  5. its a azure file system - the error seems to throw error for blob.core.windows.net, where as I am saving data to file.core.windows.net. What changes should I do in config / settings?
Peter Pan
  • 23,476
  • 4
  • 25
  • 43
sabkaraja
  • 342
  • 4
  • 15

1 Answers1

0

According the source code at https://github.com/creocoder/yii2-flysystem/blob/master/src/AzureFilesystem.php#L62, it seems the package encrypt the storage info string into base64 encode before combine them into the connection string. Which makes the strange looking url format in your error message 'https://cG9rYXJuYXZpb282mGQ=.blo...'.

Please try to set the account info into following format:

...   
'accountName' => base64_decode('azure-accname'),
'accountKey' => base64_decode('some-long-key-A=='),
...

Any further concern, please feel free to let me know.

Gary Liu
  • 13,758
  • 1
  • 17
  • 32
  • the error now shows the account name and some additional characters, https://azure-accnamec=.blob.core.windows.net. however the error remains same Provided url is invalid. – sabkaraja Jun 17 '16 at 10:49
  • Thanks Gary to putting me on the right track. I have got this working like this: remove base_decode (account-name) in config and remove base_encode in the Line 62 of https://github.com/creocoder/yii2-flysystem/blob/master/src/AzureFilesystem.php#L62 Since your tip lead me to the solution, I am marking your comment as answer. thanks – sabkaraja Jun 17 '16 at 11:37