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

Private file system #66

Closed
carstenjaksch opened this issue Feb 20, 2024 · 13 comments
Closed

Private file system #66

carstenjaksch opened this issue Feb 20, 2024 · 13 comments

Comments

@carstenjaksch
Copy link

Please describe the feature you would like to see implemented.

Today I learned about the private file system and that our product configurator (image uploads for product customization) uses that to store files.

Unfortunately, we need customer files on a CDN, because they are large in numbers and consume a ton of storage. Our live server storage is limited and upgrades are expensive as hell.

I found this issue: #30

Is there really no way a private file system adapter could work with this extension?

@tinect
Copy link
Member

tinect commented Feb 20, 2024

Yes this works for this plugin, but there might be different credentials needed, while the storage should NOT be accessible through http access.

You can take a look at the file var/bunnycdn_config.yml to see how you would need to configure it and create a dedicated config file within your shopwares config/packages folder.

@carstenjaksch
Copy link
Author

Thanks for your answer.

For now, I tried the same credentials and added the config to shopware.yaml – as the docs explain it: https://developer.shopware.com/docs/guides/hosting/infrastructure/filesystem.html#configuration

I cleared the cache, but it doesn't work. The files are uploaded to the local filesystem.

Is it mandatory to create a separate file? Should this file in YAML format as in the docs or follow your format with {}? Does the file name matter?

This is my config:

shopware:
  filesystem:
    private:
      visibility: "private"
      type: "bunnycdn"
      url: "..."
      config:
        endpoint: "https://storage.bunnycdn.com"
        storageName: "..."
        subfolder: ""
        apiKey: "..."
        useGarbage: true
        neverDelete: false

@tinect
Copy link
Member

tinect commented Feb 20, 2024

ahhh, I'm sorry. in var/bunnycdn_config.yml the private is also declared, isn't it?
The {} do not mather, it is just another type of writing these configs.

help: copy the entire file of var/bunnycdn_config.yml to your new file and adjust the setting.
Then: remove the var/bunnycdn_config.yml and never save the plugins config again 🙈

I'll create a todo from this issue 😍 Thank you for bringing this up again.

@carstenjaksch
Copy link
Author

Thank you!

There is no private in var/bunnycdn_config.yml. I moved everything to config/packages/z-shopware.yaml, duplicated public and adapted it. Then I deleted bunnycdn_config.yml.

When I try to clear the cache, following error occurs: Unrecognized option "url" under "shopware.filesystem.private". Available options are "config", "type", "visibility".

This is the config:

shopware:
  cdn: { url: "..." }
  filesystem:
    {
      public:
        {
          type: bunnycdn,
          url: "...",
          config:
            {
              endpoint: "https://storage.bunnycdn.com",
              storageName: ...,
              subfolder: "",
              apiKey: ...,
              useGarbage: true,
              neverDelete: false,
            },
        },
      private:
        {
          visibility: private,
          type: bunnycdn,
          url: "...",
          config:
            {
              endpoint: "https://storage.bunnycdn.com",
              storageName: ...,
              subfolder: "",
              apiKey: ...,
              useGarbage: true,
              neverDelete: false,
            },
        },
      sitemap:
        {
          type: bunnycdn,
          url: "...",
          config:
            {
              endpoint: "https://storage.bunnycdn.com",
              storageName: ...,
              subfolder: "",
              apiKey: ...,
              useGarbage: true,
              neverDelete: false,
            },
        },
      theme:
        {
          type: local,
          url: "",
          config: { root: "%kernel.project_dir%/public" },
        },
      asset:
        {
          type: local,
          url: "",
          config: { root: "%kernel.project_dir%/public" },
        },
    }

@tinect
Copy link
Member

tinect commented Feb 20, 2024

as the message says: remove url from private filesystem.

Hmmm, while there was no private filesystem in the bunnycdn_config your setting as before should work 🙈
Would you please try it again? Otherwise I will reevaluate it next days.

@carstenjaksch
Copy link
Author

Sorry that I didn't mention it: I tried that already and it did not work.

The error disappears, but the files are uploaded to the local filesystem and no activity in Bunny.

@tinect
Copy link
Member

tinect commented Feb 20, 2024

hmmmm, you cleared the cache? and the var/cache/*?
But the new media is being uploaded correct? the bunnycdn_config has been removed?

while it is loading the file (regarding the previous error message) it "should" work while it shopwares defaul behaviour.

When you intend the line, the {} are not neccessary.

@carstenjaksch
Copy link
Author

Yes, the cache was cleared and bunnycdn_config.yml removed.

The files are uploaded with this extension: https://store.shopware.com/neon558587413963m/datei-upload-fuer-produkte-produkt-konfigurator-add-on.html

They use the private filesystem to upload these files.

@tinect
Copy link
Member

tinect commented Feb 21, 2024

are you able to verify the code, that they really use filesystem.private and not hardcoded local paths?

@carstenjaksch
Copy link
Author

The parent extension of this addon has some filesystem.private in src/Resources/config/services.xml:

<service id="Neon\Configurator\Controller\Storefront\NeonconfiguratorFileController" public="true">
    <argument type="service" id="shopware.filesystem.private"/>
    ...
</service>

This are the interesting parts of Neon\Configurator\Controller\Storefront\NeonconfiguratorFileController and another file:

const FILE_FOLDER_CONFIGURATOR = 'neon-configurator/'; // in another file
class NeonconfiguratorFileController extends StorefrontController
...
    $path = Neon6Configurator::FILE_FOLDER_CONFIGURATOR."uploads/tmp/";
...
    $this->fileSystem->has($path.$fileName)

They use Filesystem $filesystem all over the place with only the paths uploads/orders and uploads/tmp hard coded.

I asked them about that issue and they told me that they use the private file system.

Hope these code snippets are useful, I don't want to post too much (because paid extension).

@tinect
Copy link
Member

tinect commented Feb 21, 2024

That is totally okay regarding the plugin. That parts you posted look totally correct.
Please give me some time. I will check this next days and come back to you soon.

It might be helpful to provide me with HTTP and ssh access to a test-shop where you can reproduce it. So I can check it on site over the weekend. If it's okay for, you can contact me 1on1 at Slack. You find me as tinect.

@carstenjaksch
Copy link
Author

Thank you @tinect, you have a Slack message.

@tinect
Copy link
Member

tinect commented Feb 23, 2024

@carstenjaksch As mentioned in 1on1 chat, this is no issue with this plugin, but the one of neon6configurator.

you can create a dedicated yaml file as mentioned above. the storage should not be linked to any pull zone!

shopware:
  filesystem:
    private:
      visibility: "private"
      type: "bunnycdn"
      config:
        endpoint: "https://storage.bunnycdn.com"
        storageName: "..."
        subfolder: ""
        apiKey: "..."
        useGarbage: true
        neverDelete: false

@tinect tinect closed this as not planned Won't fix, can't repro, duplicate, stale Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants