edwardspec / mediawiki-aws-s3

Extension:AWS allows MediaWiki to use Amazon S3 (instead of the local directory) to store images.
https://www.mediawiki.org/wiki/Extension:AWS
GNU General Public License v2.0
42 stars 32 forks source link

Can't use with MinIO #46

Closed vagile-cn closed 2 years ago

vagile-cn commented 2 years ago

MinIO CopyObject look like Not Found image

edwardspec commented 2 years ago

Any errors/details in server/audit logs?

vagile-cn commented 2 years ago

I think that mean the CopyObject method is removed in MinIO, can any other method replace this method?

edwardspec commented 2 years ago

MinIO code says that it supports CopyObject. Without additional information from your logs (that shows what and where was being copied, and what was the exact reason), there is no way to know what's going on.

See MinIO documentation for how to get the logs.

vagile-cn commented 2 years ago

I can't find how to turn on the audit logs I watch the bucket file and get the result image then I trace the request image

this is the result in mediawiki image

edwardspec commented 2 years ago

Please add the following to LocalSettings.php: $wgDebugLogGroups['FileOperation'] = '/path/to/logfile.txt'; (change /path/to/logfile.txt to whatever, this file should be writable by webserver)

This log will at least tell us what is being copied from where to where. Screenshots above don't tell us anything.

Also note that CopyObject is only used when deleting/renaming/reuploading files. It's not used when uploading a new file.

vagile-cn commented 2 years ago

let me get log.... are you sure minio support CopyObject? image

vagile-cn commented 2 years ago

2021-11-01 08:05:10 vz-wiki3d wiki3d: S3FileBackend: found backend with S3 buckets: minio/wiki3d/update, minio/wiki3d/update/thumb, minio/wiki3d/update/deleted, minio/wiki3d/update/temp. 2021-11-01 08:05:10 vz-wiki3d wiki3d: S3FileBackend: doPrepareInternal: S3 bucket minio, dir=wiki3d/update/temp/, params=noAccess, noListing, dir 2021-11-01 08:05:10 vz-wiki3d wiki3d: S3FileBackend: doCreateInternal(): saving wiki3d/update/temp/20211101080510!phpqoiAFA.png in S3 bucket minio (sha1 of the original file: gkqx7kbwlhf87k66o4x42m4opa07bl6, Content-Type: image/png) 2021-11-01 08:05:10 vz-wiki3d wiki3d: S3FileBackend: Performance: 0.099 second spent on: uploading wiki3d/update/temp/20211101080510!phpqoiAFA.png to S3 2021-11-01 08:05:10 vz-wiki3d wiki3d: S3FileBackend: doGetFileStat(): obtaining information about wiki3d/update/temp/20211101080510!phpqoiAFA.png in S3 bucket minio 2021-11-01 08:05:10 vz-wiki3d wiki3d: S3FileBackend: doPrepareInternal: S3 bucket minio, dir=wiki3d/update/temp/, params=noAccess, noListing, dir 2021-11-01 08:05:10 vz-wiki3d wiki3d: S3FileBackend: doCopyInternal(): copying wiki3d/update/temp/20211101080510!phpqoiAFA.png from S3 bucket minio to wiki3d/update/temp/18qmmx8rbo44.1dmztw.1.png.0 from S3 bucket minio. 2021-11-01 08:05:10 vz-wiki3d wiki3d: S3FileBackend: exception NoSuchBucket in doCopyInternal from CopyObject ({"ACL":"private","Bucket":"minio","CopySource":"minio/wiki3d/update/temp/20211101080510%21phpqoiAFA.png","Key":"wiki3d/update/temp/18qmmx8rbo44.1dmztw.1.png.0","MetadataDirective":"COPY","@http":[],"@context":[]}): Error executing "CopyObject" on "http://minio.vz-minio:9000/wiki3d/update/temp/18qmmx8rbo44.1dmztw.1.png.0"; AWS HTTP error: Client error: PUT http://minio.vz-minio:9000/wiki3d/update/temp/18qmmx8rbo44.1dmztw.1.png.0 resulted in a 404 Not Found response: <?xml version="1.0" encoding="UTF-8"?>

NoSuchBucketThe specified bucket does not exist NoSuchBucketThe specified bucket does not existwiki3d/update/temp/20211101080510!phpqoiAFA.pngminio/wiki3d/update/temp/18qmmx8rbo44.1dmztw.1.png.016B35D83D1F28B429510dd87-3f33-4533-a41a-1c830749457a 2021-11-01 08:05:10 vz-wiki3d wiki3d: S3FileBackend: found non-existent S3 bucket minio, going to create it 2021-11-01 08:05:10 vz-wiki3d wiki3d: S3FileBackend: exception BadRequest in doCopyInternal from CreateBucket ({"ACL":"private","Bucket":"minio","@http":[],"@context":[]}): Error executing "CreateBucket" on "http://minio.vz-minio:9000/"; AWS HTTP error: Client error: `PUT http://minio.vz-minio:9000/` resulted in a `400 Bad Request` response: BadRequestAn error occurred when parsing the HTTP re (truncated...) BadRequest (client): An error occurred when parsing the HTTP request PUT at '/' - BadRequestAn error occurred when parsing the HTTP request PUT at '/'/9510dd87-3f33-4533-a41a-1c830749457a 2021-11-01 08:05:10 vz-wiki3d wiki3d: S3FileBackend: Performance: 0.012 second spent on: copying S3 object wiki3d/update/temp/20211101080510!phpqoiAFA.png to wiki3d/update/temp/18qmmx8rbo44.1dmztw.1.png.0 2021-11-01 08:05:10 vz-wiki3d wiki3d: CopyFileOp failed (batch #): {"src":"mwstore://AmazonS3/local-temp/20211101080510!phpqoiAFA.png","dst":"mwstore://AmazonS3/local-temp/18qmmx8rbo44.1dmztw.1.png.0","overwrite":true,"headers":[],"failedAction":"attempt"}
edwardspec commented 2 years ago

are you sure minio support CopyObject?

https://github.com/minio/minio/blob/3837d2b94becf95532cbc91024fa2ac7dd6c13e1/cmd/gateway/s3/gateway-s3.go#L539

vagile-cn commented 2 years ago

are you sure minio support CopyObject?

https://github.com/minio/minio/blob/3837d2b94becf95532cbc91024fa2ac7dd6c13e1/cmd/gateway/s3/gateway-s3.go#L539

=_= okkkkk but why I got the not found result = = sorry for the inconvenience = =~~~

edwardspec commented 2 years ago

NoSuchBucket in doCopyInternal from CopyObject ({"ACL":"private","Bucket":"minio","CopySource":"minio/wiki3d/update/temp/20211101080510%21phpqoiAFA.png","Key":"wiki3d/update/temp/18qmmx8rbo44.1dmztw.1.png.0",

Returns NoSuchBucket for some reason. Per the log, both Bucket and CopySource parameters use the correct bucket name (minio), as the same bucket name worked in doCreateInternal() earlier (which does PutObject).

The reason is unknown, but the error is not on the side of Extension:AWS (it calls the method with correct parameters). Must be a misconfiguration of minio or something.

vagile-cn commented 2 years ago

I have another question that I use my minio server that url is http://vz-minio:9000 when I set the bucketName to wiki3d the url will change to http://wiki3d.vz-minio:9000 how can I use minio with http://vz-minio:9000? I think the question whth CopyObject may be is because that I set the bucketName to minio to use the url http://minio.vz-minio:9000 thanks so much

edwardspec commented 2 years ago

Probably needs $wgAWSBucketDomain = 'vz-minio:9000';

vagile-cn commented 2 years ago

I was set $wgAWSBucketDomain to the url to visit MinIO's file but the log mean mediawiki still upload file to http://wiki3d.vz-minio:9000

edwardspec commented 2 years ago

Ok, these are two different things entirely. $wgAWSBucketDomain affects public URLs (from which the visitors download images), nothing more.

When doing internal API requests, AWS client always prepends bucket name to endpoint. This is intended behavior.

So you should have wiki3d.vz-minio, minio.vz-minio, etc. pointed to the same IP address as vz-minio (e.g. in /etc/hosts).

vagile-cn commented 2 years ago

I change the para that set $wgFileBackends['s3']['endpoint'] = 'http://vz-minio:9000/wiki3d/'; $wgAWSBucketName = "wiki3d"; $wgAWSBucketTopSubdirectory="/update";

and public url is $wgAWSBucketDomain = 'https://my_url/wiki3d';

but I get upload file url is https://https//my_url/wiki3d/update/Image2.png

what's happend = =

edwardspec commented 2 years ago

Remove the protocol from $wgAWSBucketDomain. Domain name (and port if needed) only.

vagile-cn commented 2 years ago

Remove the protocol from $wgAWSBucketDomain. Domain name (and port if needed) only.

but..... how can I use it with http?

edwardspec commented 2 years ago

Not supported.

vagile-cn commented 2 years ago

Not supported.

ok~~~ thanks u very much