Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import images from secured path #354

Open
EnzephaloN opened this issue Nov 14, 2024 · 1 comment
Open

Import images from secured path #354

EnzephaloN opened this issue Nov 14, 2024 · 1 comment
Labels

Comments

@EnzephaloN
Copy link

EnzephaloN commented Nov 14, 2024

Hello

Is it possible to import images from path, which is secured by EXT:secure_downloads? If its possible, how to write TCA-part for this? This path denies direct access by htaccess.

Actually I have this configuration:

$GLOBALS['TCA']['tx_cartproducts_domain_model_product_product']['columns']['images']['external'] = [
    0 => [
        'field' => 'bildurl',
        'transformations' => [
            10 => [
                'trim' => true
            ],
            20 => [
                'userFunction' => [
                    'class' => \Cobweb\ExternalImport\Transformation\ImageTransformation::class,
                    'method' => 'saveImageFromUri',
                    'parameters' => [
                        'storage' => '1:productimport',
                        'nameField' => 'sku',
                        'defaultExtension' => 'jpg'
                    ]
                ]
            ]
        ],
        'children' => [
            'table' => 'sys_file_reference',
            'columns' => [
                'uid_local' => [
                    'field' => 'images',
                ],
                'uid_foreign' => [
                    'field' => '__parent.id__'
                ],
                'title' => [
                    'field' => 'sku'
                ],
                'tablenames' => [
                    'value' => 'tx_cartproducts_domain_model_product_product'
                ],
                'fieldname' => [
                    'value' => 'image'
                ],
                'table_local' => [
                    'value' => 'sys_file'
                ]
            ],
            'controlColumnsForUpdate' => 'uid_local, uid_foreign, tablenames, fieldname, table_local',
            'controlColumnsForDelete' => 'uid_foreign, tablenames, fieldname, table_local'
        ]
    ]
];

I think saveImagesFrom Uri isn't the best method to do this, maybe there is a better way?

Best regards
EnzephaloN

@fsuter
Copy link
Contributor

fsuter commented Nov 16, 2024

Hi. This will definitely not work as is with "saveImageFromUri". I'm not sure how I would proceed with that myself, but one way I can think of is to create your own version of said method and add to it a process of authenticating with the TYPO3 frontend that you are querying. Then you should be able to use the secured URIs provided by secure_downloads to retrieve the file. Or maybe there's some event or hook in secure_downloads which would enable you to bypass the usual process using some other method to secure the exchange (it could just be the IP address, which is not foolproof, or an exchange of tokens).

Anyway, it's not something that can be provided out of the box by External Import, as it is a very specific situation. Indeed the ImageTransformation class - although quite useful as is - is also meant to be an inspiration or code base for more complex scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants