Using DigitalOcean Spaces or Amazon S3 for file storage in XF 2.1+

Using DigitalOcean Spaces or Amazon S3 for file storage in XF 2.1+

No permission to download
I get this error:

PHP:
Aws\S3\Exception\S3Exception: Error executing "PutObject" on "MY_S3_IP_ADDRESS/data/avatars/o/0/5.jpg";
AWS HTTP error: cURL error 6: Could not resolve host: data.MY_S3_IP_ADDRESS;
Unknown error (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) src/addons/XFAws/_vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php:191

I assume this is because it tries to use data as prefix in the url because it says "Could not resolve host: data.MY_S3_IP_ADDRESS"

My bucket's url doesn't have a prefix at all but it tries to apply that hence why it can't resolve it.

What to do here?
 
every bucket is in at least 1 region.

what does it say? make sure it lines up to your config.php code
As I said, I am not using Amazon S3.

Also I am totally sure the region is not the problem. Because when I edited my config file, I intentionally left out "version" and "region" lines. Then the XF console threw errors that they were missing. After that I just added an empty region and "latest", and the errors are gone.

The only problem I believe is that the adapter of XF can't find the url because it somehow adds a prefix to the url, but my bucket has no prefix.
It tries to access data.blabla.com and my site is just blabla.com.
 
ahh, sorry, i missed that on the previous page. I have never used that other service so not sure any of what i said is relevant.
 
  • Like
Reactions: sbj
ahh, sorry, i missed that on the previous page. I have never used that other service so not sure any of what i said is relevant.
No problem. Could you check sth. for me please?
If you go to your bucket, what is the url of it?
 
it says it's fully 100% compatible with s3, so there must be a region code to use even if it's a default one. s3 requires it for put commands. Perhaps it defaults natively internally...

It's asking me for credit card info before i can see anything, so i'm out. sorry.
 
  • Like
Reactions: sbj
it says it's fully 100% compatible with s3, so there must be a region code to use even if it's a default one. s3 requires it for put commands. Perhaps it defaults natively internally...

It's asking me for credit card info before i can see anything, so i'm out. sorry.
Ah, I thought you are on S3. Nvm it.
On whatever provider you are, could you give an example of your bucket url? Like if you connect to that site and go to your bucket, copy/paste it from the browser.
 
my config file looks like this:

Code:
//S3 attachments
$s3 = function()
{
   return new \Aws\S3\S3Client([
      'credentials' => [
         'key' => 'nope',
         'secret' => 'super nope'
      ],
      'region' => 'us-east-1',
      'version' => 'latest',
      'endpoint' => 'https://s3.us-east-1.amazonaws.com'
   ]);
};

//public data
$config['fsAdapters']['data'] = function() use($s3)
{
   return new \League\Flysystem\AwsS3v3\AwsS3Adapter($s3(), 'mybucket', 'data');
};

//private data
$config['fsAdapters']['internal-data'] = function() use($s3)
{
   return new \League\Flysystem\AwsS3v3\AwsS3Adapter($s3(), 'mybucket', 'pdata');
};

//serving via cloudfront by means of CNAME from cdn -> mycloudfront url
$config['externalDataUrl'] = function($externalPath, $canonical)
{
   return 'https://cdn.mydomain.com/' . $externalPath;    //data folder is built in to the cloudfront settings, not required before externalPath
};
 
  • Like
Reactions: sbj
Good news is I could solve the problem from above by adding 'use_path_style_endpoint' => true to the config file.
Bad news is now I get a connection refused error :D. Maybe I'll figure this one out, too. I am sure all permissions are set correctly, but...yeah.
 
@Chris D

Thanks for the guide! Fantastic, but I have a major issue:
I use XenCentral Multisite System and for some reason the sitemap isnt generated from the 2nd subdomain I added. Same database, same files etc..., but for some reason I dont have a separate sitemap... and if I rebuild the sitemap from the domain2.com/admin.php - Tools - Rebuild sitemap there's no file that get generated.

Do you have any idea or recommendation? It somehow seems like the 2nd domain dont have a permission to create sitemap file in it.
(Uploading attachments and everything else works from the 2nd domain, only sitemap isnt).
 
Is it possible to only associate the data folder and attachments, BUT the internal_data folder (and sitemaps folder) is not on Digital Ocean's space?

XCentral said they cant use Digital Ocean's sitemaps...
 
Top Bottom