Calling Developers!
We are reenergizing our code contribution process! Learn More

FTP OR SFTP use

Options
bhupendra.doniwal
bhupendra.doniwal Posts: 41 πŸ§‘πŸ»β€πŸš€ - Cadet

Hi team,

I've got my FTP credentials ready. Now, I'm looking to push files into it. Could you please provide guidance on how to do this? Alternatively, is there a module I can refer to for assistance?

Thank you.

Best regards,
Bhupendra

Comments

  • bhupendra.doniwal
    bhupendra.doniwal Posts: 41 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited March 27
    Options

    .

  • victor.vanherpt
    victor.vanherpt Spryker Solution Partner Posts: 34 πŸͺ - Explorer
    edited March 28
    Options

    @bhupendra.doniwal, In our project we use the flysystemService, together with config settings to set the destination filesystems (be it FTP/SFTP/S3 buket)

    This is a particular bit that is writting a file into the flysystemService, in case it helps you:

    In this bit, the $fileSystem is a string referencing the key in the FileSystemConstants::FILESYSTEM_SERVICE config setting.
    I'd say also check the filesystem and flysystem docs:
    https://docs.spryker.com/docs/dg/dev/backend-development/data-manipulation/data-ingestion/structural-preparations/file-system.html#the-codefilesystemcode-module
    https://docs.spryker.com/docs/dg/dev/backend-development/data-manipulation/data-ingestion/structural-preparations/flysystem.html#module-dependency-graph

  • bhupendra.doniwal
    bhupendra.doniwal Posts: 41 πŸ§‘πŸ»β€πŸš€ - Cadet
    Options

    Thank you for your reply, @victor.vanherpt.

    I've managed to connect to my FTP server using Flysystem and can successfully write files to it. Now, my goal is to push my exported order files to the FTP server. Do you have any suggestions on how to achieve this?

    Appreciate your assistance.

    Best regards,
    Bhupendra

  • victor.vanherpt
    victor.vanherpt Spryker Solution Partner Posts: 34 πŸͺ - Explorer
    edited March 28
    Options

    I think that's more application logic, no? If you are writting the files successfuly, you just need update the function so that it will write through the flysystemService. Or write a function that will read each of the files from the export directory and write into the filesystem.

    If by 'push my exported order files' you mean that you used the DataExport module… I just had a quick look and apparently it's not using Spryker's filesystem module, and I don't have experience with it.

    I'd say you need to create a plugin that will implement the DataExportConnectionPluginInterface ( vendor/spryker/data-export-extension/src/Spryker/Service/DataExportExtension/Dependency/Plugin/DataExportConnectionPluginInterface.php). Not sure if there's anything out of the box.


    Probably someone with more experience with the DataExport module will be able to help you better.

  • bhupendra.doniwal
    bhupendra.doniwal Posts: 41 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited March 28
    Options

    @fsmeier do you know how I can change the connection? to directly export ftp

    or is there any global configuration where all the files directly point to my ftp ?

  • fsmeier
    fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,016 βš–οΈ - Guardians (admin)
    Options

    Heyhey @bhupendra.doniwal ,

    I am also not an expert in this area but @victor.vanherpt provided already pretty good ideas!

    I would do something like the following:

    1. create the plugin src/Pyz/Service/Flysystem/Plugin/DataExport/FlysystemFtpDataExportConnectionPlugin.php (or any other more suitable name) which implements the DataExportConnectionPluginInterface
    2. Use the FlysystemService to write to your ftp within the write() method of your newly created plugin (have also a look into vendor/spryker/data-export/src/Spryker/Service/DataExport/Writer/DataExportLocalWriter.php which is the default writer to write the files locally as fallback)
    3. Register your plugin in src/Pyz/Service/DataExport/DataExportDependencyProvider.php

    All the best,

    Florian