External assets are not exported/imported when using S3

Created on 5 September 2023, over 1 year ago
Updated 13 September 2023, over 1 year ago

The current version does not support media if the media is external and thus not included as assets in the zip file.
Please can you include better support for external assets so the module can force asset download and put them in the zip upon import.

πŸ› Bug report
Status

Fixed

Version

1.4

Component

Code

Created by

πŸ‡²πŸ‡¦Morocco kamalMaroc

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

Comments & Activities

  • Issue created by @kamalMaroc
  • Assigned to nginex
  • πŸ‡ΊπŸ‡¦Ukraine nginex

    Will be developed for 1.4.x and backported to 1.3.x

  • @nginex opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡¦Ukraine nginex

    There are two ways of external assets support:

    1. When exporting content, force external assets download and put them into generated zip.
    2. When importing content, force external assets download and save the files into proper uri.

    I've provided MR that supports 2nd option. Please check it, in my case everything worked well when I used s3 with two different root folders for different environments.

  • @nginex opened merge request.
  • πŸ‡ΊπŸ‡¦Ukraine nginex

    MR 65 for 1.4.x
    MR 66 for 1.3.x

  • πŸ‡²πŸ‡¦Morocco meryem dibe

    Hello,
    For the first option i have edited the function to force download of the assets
    here is my code :

     protected function addAssetsToZip(ArchiverInterface $zip): void {
        $assets = $this->privateTempStore->get('export.assets') ?? [];
    
        foreach ($assets as $file_uri) {
          // Extract the relative path from the URI.
          $file_relative_path = explode('://', $file_uri)[1];
    
          // Download the file and add it to the ZIP archive.
          $file_contents = file_get_contents($file_uri);
          if ($file_contents !== false) {
            
            // Add file contents to the ZIP archive with the same relative path.
            $zip->getArchive()->addFromString("assets/{$file_relative_path}", $file_contents);
          }
        }
    
        // Clean up the storage after we exported assets to the zip.
        $this->privateTempStore->delete('export.assets');
      }
    

    I've created a patch for it external_assets.patch
    Now im trying to import content and uploading assets (in my assets folder in the zip file ), but it seems like we only can upload files from the yml file.
    Any ideas to manage to upload files using the asset folder ?

  • πŸ‡ΊπŸ‡¦Ukraine nginex

    Thanks for the patch @Merrydbe,

    I also did fix the issue you had, please check the updated patch.

    • nginex β†’ committed aa639cd6 on 1.4.x
      Issue #3385412: Add better support for external files during content...
    • nginex β†’ committed 8aebdbf8 on 1.3.x
      Issue #3385412: Add better support for external files during content...
  • Status changed to Fixed over 1 year ago
  • πŸ‡ΊπŸ‡¦Ukraine nginex

    The fix seems wotking, going to create a new release.

    Thanks for the support.

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

Production build 0.71.5 2024