BrandOriented / PimcoreCiHubConnector

This bundle adds full integration between Pimcore and CI-HUB Connector. Now you can add, delete and download all assets, lock and unlock, get all versions for specified asset and much more.
https://brandoriented.io/
Other
5 stars 6 forks source link

CI-HUB does not download images #24

Closed betterapp closed 8 months ago

betterapp commented 8 months ago

Pimcore version(s) affected

11

Description

I have CI-HUB plugin installed in inDesign. Have configured the connection between inDesign and Pimcore

When I walk throw assets folder I have two issue:

1. Image thumbnails are not downloaded. image

On server side I see only OPTIONS requests:

[04/Mar/2024:09:18:07 +0100] "OPTIONS /datahub/rest/test/asset/download?id=25&thumbnail=galleryThumbnail HTTP/1.1" 204 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
[04/Mar/2024:09:18:07 +0100] "OPTIONS /datahub/rest/test/asset/download?id=24&thumbnail=galleryThumbnail HTTP/1.1" 204 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
[04/Mar/2024:09:18:07 +0100] "OPTIONS /datahub/rest/test/asset/download?id=23&thumbnail=galleryThumbnail HTTP/1.1" 204 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"

After my last fix (https://github.com/BrandOriented/PimcoreCiHubConnector/pull/21) CI-HUB Connector now send correct 204 response but still no thumbnails and images at all

  1. When I try to download the specific image I get CORS error image

In our logs we see: OPTIONS request for this image but nothing more [04/Mar/2024:09:44:50 +0100] "OPTIONS /datahub/rest/jysk/asset/download?id=23 HTTP/1.1" 204 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"

OPTIONS /datahub/rest/jysk/asset/download?id=23 HTTP/1.1
X-Forwarded-For: 164.90.205.110
X-Forwarded-Proto: https
X-Forwarded-Port: 443
Host: ****
X-Amzn-Trace-Id: Root=1-65e58577-46563ebc3f4ef7831f3f5626
accept: */*
access-control-request-method: GET
access-control-request-headers: authorization
origin: https://ci-hub.azurewebsites.net/
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36
sec-fetch-mode: cors
sec-fetch-site: cross-site
sec-fetch-dest: empty
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9

HTTP/1.1 204 No Content
Server: nginx
Connection: keep-alive
Allow: GET, OPTIONS
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, OPTIONS
Access-Control-Allow-Headers: authorization
Cache-Control: private, must-revalidate
Date: Mon, 04 Mar 2024 08:25:27 GMT
Pragma: no-cache
Expires: Tue, 01 Jan 1980 00:00:00 GMT
X-Powered-By: pimcore
Content-Language: en
X-Debug-Token: 32c872
X-Debug-Token-Link: ****/_profiler/32c872
X-Robots-Tag: noindex
Strict-Transport-Security: max-age=63072000
Content-Security-Policy: default-src 'self' 'unsafe-inline' 'unsafe-eval' https: data: base-uri
Referrer-Policy: same-origin
Feature-Policy: geolocation 'none';midi 'none';sync-xhr 'self';microphone 'none';camera 'none';magnetometer 'none';gyroscope 'none';fullscreen 'self';pa yment 'none';
Permissions-Policy: geolocation=(), midi=(), sync-xhr=(self), microphone=(), camera=(), magnetometer=(), gyroscope=(), fullscreen=(self), payment=()
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff

How to reproduce

Test it

Possible Solution

Is this a bug in inDesign plugin or still something wrong on PHP site

Additional Context

No response

betterapp commented 8 months ago

There is a problem that for GET Request application does not return CORS. So question is: Should CORS be defined on Application Level (like in OPTIONS request) or on server level ?

Second thing.

In documentation we can read:

Bundle Configuration Configure the default thumbnail, which is used by CI HUB to display the preview of your Pimcore Assets:

# Default configuration for "PimcoreCIHubAdapterBundle"
pimcore_ci_hub_adapter:

    # Default image/document thumbnail settings.
    default_preview_thumbnail:

        # Defaults:
        format:              PNG
        width:               300
        height:              300
        frame:               true
        forceResize:         true

Attention: This configuration is overwritten by any image thumbnail configuration with the name of "galleryThumbnail" in the Pimcore Back-End.

but when we try download image from inDesign and use original image image

indesign plugin make such request to pimcore: GET /datahub/rest/jysk/asset/download?id=25&thumbnail=galleryThumbnail

we see thumbnail=galleryThumbnail parameter

but in the code: vendor/bo-hub/ci-hub-api-bundle/src/Controller/AssetController.php line: 446

we see:

        $thumbnail = (string) $this->request->get('thumbnail');
        if (!Thumbnail\Config::getByAutoDetect($thumbnail)) {
            throw new InvalidParameterException(['thumbnail' => 'Thumbnail [' . $thumbnail . '] does not exist']);
        }
        $defaultPreviewThumbnail = $this->getParameter('pimcore_ci_hub_adapter.default_preview_thumbnail');

        if (!empty($thumbnail) && $element instanceof Image) {
            if (AssetProvider::CIHUB_PREVIEW_THUMBNAIL === $thumbnail && 'ciHub' === $configReader->getType()) {
                $elementFile = $element->getThumbnail($defaultPreviewThumbnail);
            } else {
                $elementFile = $element->getThumbnail($thumbnail);
            }
        } else {
            $elementFile = $element;
        }

if we do not have defined galleryThumbnail on pimcore side then it will throw exception so image will not be returned. Then what for is default configuration if it is used only if thumbnail if defined in pimcore ?

Does not have any sense.

In this case when we want download only thumbnails: for image list we do not get images. If we want to get thumbnails we need to define galleryThumbnail.

If we want download original image we also get galleryThumbnail. This is wrong. inDesign plugin in this case should make a request without thumbnail parameter.

Now it use thumbnail parameter for thumbnails and for origin file.

betterapp commented 8 months ago

@labudzinski is it possible that we can talk about it via call ?

labudzinski commented 8 months ago

It was fixed on 3.0.9