Skip to content
This repository has been archived by the owner on May 21, 2021. It is now read-only.

Upload new image in update action #28

Open
bednee opened this issue Feb 26, 2017 · 6 comments
Open

Upload new image in update action #28

bednee opened this issue Feb 26, 2017 · 6 comments

Comments

@bednee
Copy link

bednee commented Feb 26, 2017

I'm trying to edit persisted record with a single image. The image was uploaded via FE. Unfortunately this is not working. A new image is uploaded but it's added to the relation instead of replacing it. The model has property of FileReference type, not ObjectStorage, as it should store only single image. However, when looking at the record in BE, I see 2 relations. Any idea what I may be doing wrong or how to fix it?

@beilm
Copy link

beilm commented Jun 19, 2017

Same with my implementation, do you have any solutions?

@Xippo
Copy link

Xippo commented Jul 3, 2017

I have the same issuse but it seems more related to extbase. The converter works fine, you get the filereference but extbase don't switch the files.

@helhum
Copy link
Owner

helhum commented Jul 3, 2017

I would recommend to always use an object storage, which will then lead to the desired behavior.

@akzeitlos
Copy link

Hello, I have the same problem. I uploaded a new image and in database the sys_file_reference is changed but in the frontend output there es used the old one. Why?

@FearFreddy
Copy link

I encountered the same problem while running it in TYPO 8.7.19 and found out, that the problem happened during the conversion of the already uploaded resource inside the UploadViewHelper. While in TYPO 7.6, $this->getValueAttribute() returns the ID of the existing upload as a string, it returns an integer in TYPO 8. This leads to TYPO not setting it as the UID of the converted FileReference, thinking there is no attached resource AND creating a second relation instead of replacing it with the newly uploaded file.

Long Story Short: Casting $resource to string before converting it did the trick for me. Maybe it helps some of you.

protected function getUploadedResource()
{
    // ...
    return $this->propertyMapper->convert((string)$resource, 'TYPO3\\CMS\\Extbase\\Domain\\Model\\FileReference');
}

@tomwarwick
Copy link

I encountered the same problem while running it in TYPO 8.7.19 and found out, that the problem happened during the conversion of the already uploaded resource inside the UploadViewHelper. While in TYPO 7.6, $this->getValueAttribute() returns the ID of the existing upload as a string, it returns an integer in TYPO 8. This leads to TYPO not setting it as the UID of the converted FileReference, thinking there is no attached resource AND creating a second relation instead of replacing it with the newly uploaded file.

Long Story Short: Casting $resource to string before converting it did the trick for me. Maybe it helps some of you.

protected function getUploadedResource()
{
    // ...
    return $this->propertyMapper->convert((string)$resource, 'TYPO3\\CMS\\Extbase\\Domain\\Model\\FileReference');
}

This fixed the exact same issue for me - thank you very much.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants