New action: save file from string data

Created on 8 December 2023, about 1 year ago
Updated 17 May 2024, 7 months ago

Problem/Motivation

Using remote APIs, sometimes they can return files as base64 encoded strings. It would be useful to have an action that could take that string and save it into Drupal.

Proposed resolution

Add a new action that can read a token from a previous result (file data), and save it to the file system.

✨ Feature request
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States kevinquillen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @kevinquillen
  • Status changed to Needs work about 1 year ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    I've had a first look into this and it looks really great. Only have a few recommendations and thoughts:

    • We're only developing new features in the 2.0.x branch. Please rebase.
    • This should not go into the eca_content submodule, we should rather introduce an eca_file submodule which will then receive a few more action plugins as well (see ✨ Add new submodule ECA FileSystem Active .
    • This action plugin should not worry about base64 decoding as there is already Tamper: Encode/Decode which also does base64 decoding.
    • Also, I wonder if this action should only create a file in the file system. Taking that file to create a managed file entity from it should probably be a separate action plugin. The handling of creating the file should be done similarly to Views: Export query into file
    • There are a couple of issue regarding coding standards, they will be tested and reported when pushing to the 2.0.x branch and should then also be removed.

    Let me know if you feel that we should first build the eca_file submodule foundation in the linked issue, if that makes the development here easier to follow-up.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Rebased for the 2.0.x branch.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen
  • Assigned to jurgenhaas
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    I'm looking into this now as part of ✨ Add new submodule ECA FileSystem Active .

  • Status changed to Fixed 8 months ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    This is now implemented with a much simpler approach: this action plugin requires a file entity and a data field, which contains the content that should be written to the file of the given entity.

    This way, it can be used in all different scenarios. First you create a file entity and define the schema, filename, extension, etc. there. Then you prepare the file content in a token, which then gets written to that file. Fully flexible and allows the site builder to do anything around writing data to files.

    Closing the MR for that reason, since this is now already in 2.0.x-dev

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024