在 Drupal 8 中使用 'Dropzonejs module' 在站点服务器上'Media bulk upload'给出"failed to open the output strea



我的网站使用Drupal 8,我们使用Dropzonejs模块进行"媒体批量上传"选项。在我的本地环境中,我可以毫无问题地批量上传媒体。但是,在服务器环境(具有与本地相同的配置(上,当我尝试批量上传媒体时,它会引发"无法打开输出流"错误。任何解决方案/答案/建议都是非常欢迎和非常需要的。

注意:单个项目上传工作正常。同样在批量上传期间,一旦进度条达到 100%,就会发生错误。

缺陷截图在这里

从 Drupal 8.6 开始,我们需要在核心中有一个补丁才能使此功能正常工作。对于修复,需要更改三个文件,如下所示:

  1. drupal/core/include/files.inc(第 234 行(

    /* @var \Drupal\Core\StreamWrapper\StreamWrapperInterface $wrapper */ if ($wrapper = \Drupal::service('stream_wrapper_manager'(->getViaUri($uri(( { 返回 $wrapper->getExternalUrl((;}返回假;

  2. drupal/core/modules/locale/src/StreamWrapper/TranslationsStream.php(第 48 行替换函数(

    public function getExternalUrl() {
    return FALSE;
    

    }

3.drupal/core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php(在第 365 行添加(

       * Tests that imported PO files aren't break the UI provided by "views".
   *
   * @throws BehatMinkExceptionExpectationException
   *
   * @link https://www.drupal.org/project/drupal/issues/2449895
   */
  public function testPoFileImportAndAccessibilityOfFilesOverviewViewsPage() {
    $this->container
      ->get('module_installer')
      ->install(['system', 'user', 'file', 'views']);
    // Create and log in a user that's able to upload/import translations
    // and has an access to the overview of files in a system.
    $this->drupalLogin($this->drupalCreateUser([
      'access administration pages',
      'access files overview',
      'administer languages',
      'translate interface',
    ]));
    // Import a dummy PO file.
    $this->importPoFile($this->getPoFile(), [
      'langcode' => 'fr',
    ]);
    // The problem this test cover is exposed in an exception that is thrown
    // by the "DrupallocaleStreamWrapperTranslationsStream" when "views"
    // module provides a page of files overview. Refer to the issue to find
    // more information.
    $this->drupalGet('admin/content/files');
    $this->assertSession()->statusCodeEquals(200);
  }

(在第 373 行,覆盖以下函数(

   public function importPoFile($contents, array $options = []) {
    $file_system = $this->container->get('file_system');
    $file_path = $file_system->tempnam('temporary://', 'po_') . '.po';
    file_put_contents($file_path, $contents);
    $options['files[file]'] = $file_path;
    $this->drupalPostForm('admin/config/regional/translate/import', $options, 
    t('Import'));
    $file_system->unlink($file_path);
  }

相关内容

最新更新