I am using s3fs_cors along with inline_entity_form and entity_browser, and have been experiencing issues with getting the upload to work.

I have an s3fs_cors field on a media entity called 'File'. Uploads work fine when adding via media/add/file.

Another way that I can upload files is through a normal content type (Article) and clicking the File icon in the ckeditor for the body field. This is set up to open an Entity Browser that displays the media file form in an iframe. This is where the file upload fails, so I started digging in. This actually lead to two different problems. The first one was solved by this patch: https://www.drupal.org/project/s3fs_cors/issues/2985826. After using that patch, there wouldn't be a javascript error (because of not using the correct field name), but the file field would just disappear after selecting a file to upload. This is because the value passed in `element_parents` is incorrect. The JS code always sets `element_parents` to `field_name_key + '/widget'`, but it should be set to an implosion of the element's parents. I've found by changing it to this, it now works with entity_browser, and also still works on media/add/file.

Patch to follow.

Comments

bdlangton created an issue. See original summary.

bdlangton’s picture

Status: Active » Needs review
StatusFileSize
new1.34 KB
bdlangton’s picture

StatusFileSize
new1.38 KB

The previous patch only applies cleanly after the patch here is applied: https://www.drupal.org/project/s3fs_cors/issues/2985826

So here is a new patch that applies against 8.x-1.x.

  • jlscott committed 3fba7f0 on 8.x-1.x authored by bdlangton
    Issue #2991995 by bdlangton: element_parents in the POST url not always...
jayelless’s picture

@bdlangton. Thanks for the patch. Now committed.

jayelless’s picture

Status: Needs review » Fixed
jayelless’s picture

Status: Fixed » Needs work

Re-opening this issue, as the applied patch results in the following messages in the watchdog log:

Notice: Undefined index: #prefix in Drupal\file\Element\ManagedFile::uploadAjaxCallback()
Notice: Undefined index: #suffix in Drupal\file\Element\ManagedFile::uploadAjaxCallback()

and the display does not correctly update with the uploaded file.

jayelless’s picture

StatusFileSize
new925 bytes

New patch attached. Apply to latest dev version (or after applying one of the previous patches for this issue).

jayelless’s picture

@bdlangton: Can you please confirm that your system still uploads correctly with the patch from #8 applied? Please also confirm that it continues to work when the field is configured for more than one file. Thanks.

jayelless’s picture

Status: Needs work » Needs review
jayelless’s picture

Assigned: Unassigned » jayelless
StatusFileSize
new892 bytes

Patch re-rolled for latest version.

@bdlangton: Can you please confirm that your system still uploads correctly with this patch applied? Please also confirm that it continues to work when the field is configured for more than one file. Thanks.

bdlangton’s picture

@jlscott Sorry for the delay. The patch still works for me and works when using it on a multi-value field.

  • jlscott committed 7e0be26 on 8.x-1.x
    Issue #2991995 by jlscott, bdlangton: element_parents in the POST url...
jayelless’s picture

Thanks @bdlangton. Patch committed.

jayelless’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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