cancel
Showing results for 
Search instead for 
Did you mean: 

Media/MIME config in Vocabulary-based SEGW project

Attila
Active Participant
0 Kudos

Dear Gurus,

I successfully implemented an SEGW  project with SAP Annotations already, which is working properly and managing attachments. Now I want to do the same within a project of Vocabulary-based annotations.

I got the error: 415 (Unsupported Media Type). This is due I do not know, how-to configure the entity and its properties in SEGW to set this entity as Media Type, I feel myself a bit lost.

What I already did, is that redefined the DEFINE method of Model Provider to set up the Property holding the Content Type:


  METHOD define.

    super->define( ).

    DATA(lo_entity_type) = model->get_entity_type( iv_entity_name = gc_attachment ).

    IF lo_entity_type IS BOUND.

      lo_entity_type->get_property( iv_property_name = 'MimeType' )->set_as_content_type( ).

    ENDIF.

  ENDMETHOD.

set IsMediaType for the MimeType property

set MediaType for the binary content

set allowed file extensions both in MimeType and Content properties

and set MediaResource configuration, but all unsuccessfully:

I wiped the cache and got the same issue time to time in the standard, when processing a newly created entities. The processing in the gateway is dependent of  the following statement: lo_entity_type->has_stream( ), which is always false, and therefore the entity is evaluated not as a Media(and in metadata there is no HasStream attribute for my Attachment entity), and the exception 415 (Unsupported Media Type) is raised by the GateWay. Our release is GW 740sp11.

Any advise is welcome

Thank you

Accepted Solutions (1)

Accepted Solutions (1)

Sophie_V
Advisor
Advisor
0 Kudos

Hi Attila,

We would like to manage attachments within the same kind of projects.

And it's really tricky to find documentation on that topic.

Have you found any solutions for your Vocabulary-based annotation project?

Best regards,

Sophie

Attila
Active Participant
0 Kudos

Hi Sophie,

I found no documentation unfortunately. But complementing the above, you need to add the following statement in the redefinition of method DEFINE in the model provider (*MPC_EXT) class: lo_entity_type->set_is_media('X' ).

So the method looks like this:


  METHOD define.

    super->define( ).

    DATA(lo_entity_type) = model->get_entity_type( iv_entity_name = gc_attachment ).

    IF lo_entity_type IS BOUND.

      lo_entity_type->set_is_media( iv_is_media = abap_true ).

      lo_entity_type->get_property( iv_property_name = 'MimeType' )->set_as_content_type( ).

    ENDIF.

  ENDMETHOD.

Bets regards

Attila

P.S.:

I address the service using a sap.m.uploadcollection. If you need some snippets focusing on critical points (but not explaining the parts after the service received the data), you can find here, it will work with vocabulary based projects also.

Answers (2)

Answers (2)

cuong_luc
Explorer
0 Kudos

Hi attila.berencsi,

Can you share your code a little bit, now I'm implementing a fiori app using service with vocabulary-based annotations and using UploadSet for uploading files, but it takes direct url to where files are stored, whiles service with vocabulary-based annotations is always sending $batch requests to backend, so I don't know how to apply UploadSet to service with vocabulary-based annotations.

It is very great, if you can share it!

Thanks & Best Regards,

Dinh Cuong Luc

Attila
Active Participant

Hi Dinh Cuong Luc,

I've those snippets not anymore in my hands, they are gone with my old site into a database backup.
Sorry 😞
Bets regards, Attila

cuong_luc
Explorer
0 Kudos

Hi Attila Berencsi,

No problem, now I am able to send files to the backend using UploadSet. Thank you anyway 🙂

Best Regards,

Cuong

0 Kudos

Hi,

I know this post is old but nowadays is also usefull 😉

I followed all the steps but I think I'm missing something because I'm trying to download my file by typing an URL like this ".../sap/opu/odata/sap/my_srv/AttachmentsSet('attachmentID')/$value" and I have the following error:

The request URI is not valid. The segment before '$value' must be a Media Link Entry.

Any suggestion? Thanks in advice.

PS: My Entity properties FILETYPE and FILECONTENT are configured as you say in your post. I've also redefined the "DEFINE" method from my "*MPC_EXT" class.