10up / windows-azure-storage

Use the Microsoft Azure Storage service to host your website's media files.
https://wordpress.org/plugins/windows-azure-storage/
BSD 2-Clause "Simplified" License
64 stars 46 forks source link

Plugin adding random prefix to image and error in logs #125

Closed snehaa closed 2 years ago

snehaa commented 4 years ago

Hi, Everything was working fine on my local machine installation, once I moved to hosted servers, started seeing some issues.

  1. Started seeing error Microsoft Azure Storage requires direct filesystem access in order to work. as references in issue 83 and no uploads were working, Had to add following config in wp-config for the error to disappear and uploads to work

    define(` 'FS_METHOD', 'direct' );
    define( 'DISALLOW_FILE_MODS', 'true' );
  2. Started getting this error in log PHP Warning: array_flip() expects parameter 1 to be array, object given in /var/www/wp-content/plugins/windows-azure-storage/includes/class-windows-azure-rest-api-client.php on line 1172, referer: http://static.developer.stg.walmart.com/wp-admin/upload.php As suggested in Issue 27 disabling/ deleting the plugin and reinstalling did not work and the error still persists.

  3. Plugin has started adding a random prefix and extension to the image file uploaded. eg: 5f3daf1699120-5f3daf1699122ico-forum@2x.png.png the file name was ico-forum@2x.png

I feel the 2nd and 3rd issues are related, but unable to debug, as I am new to php and wordpress.

Env variables: Wordpress: 5.3.0 Windows-azure-storage-plugin: 4.3.1 PHP: 7.2.33

rickalee commented 4 years ago

@snehaa What settings do you have for "Use Microsoft Azure Storage for all media uploads on this site." and "Keep local files after uploading them to Azure Storage."?

Does your production environment have multiple servers/nodes, if so do they share a mounted filesystem?

snehaa commented 4 years ago

These are my settings

Screen Shot 2020-09-01 at 9 30 57 AM

Does your production environment have multiple servers/nodes, if so do they share a mounted filesystem? Yes it is a multi server/node environment, we do not have a common mounted filesystem. Ideally I do not want to store any images on nodes and only use Azure storage.

rickalee commented 4 years ago

Source image must be on local server initially for the thumbnails/crops to be generated by wp_generate_attachment_metadata before they are offloaded and files are then deleted. This can be a multi-thread process across your nodes. Without a shared filesystem, it maybe trying to offload and image which may not be on current node.

snehaa commented 4 years ago

Hi @rickalee Thanks for the quick response, so basically we need to have a shared filesystem between servers, and wp-uploads should be added to the shared filesystem for the upload to work properly?

rickalee commented 4 years ago

@snehaa Correct. A mounted shared drive between servers that includes wp-content/uploads/*

zar69 commented 4 years ago

So it's possible to mount a shared drive on an Azure app service? Or do you use an IaaS setup? Best regards.

rickalee commented 4 years ago

You could do something similar to this.

https://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-use-files-linux