[ 
https://issues.apache.org/jira/browse/OLINGO-662?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14556163#comment-14556163
 ] 

Prashanth commented on OLINGO-662:
----------------------------------

Hi Christian,

Thanks for the reply. 

Following are the use cases we want to handle :
1) client would send the request for creating / updating some object ( ex: 
Issue ) and here request contains some data ( ex : issue details in the form of 
json ) + one or more files / attachments ( any type ) . 
2) client would send the request for uploading the file / attachment and gets 
back the reference ( id ) of file / attachment back as response.

Now i think you got what i meant by attachments based on the above use cases.

Coming to your suggestion of using media entity : 

I have looked into an example in the following link :
https://olingo.apache.org/doc/odata2/tutorials/read_media-resource.html . 
Here , readEntityMedia method is used for getting the image as response, which 
is ok. 

I have also looked into EntityMediaProcessor which provides three methods for 
delete,read and update. But not CREATE media.
deleteEntityMedia(DeleteUriInfo uriInfo, String contentType) 
readEntityMedia(GetMediaResourceUriInfo uriInfo, String contentType)
updateEntityMedia(PutMergePatchUriInfo uriInfo, InputStream content, String 
requestContentType, String contentType)

Currently, we are trying in the following way for handling the use cases which 
i have mentioned at the beginning . 

1) For supporting the multipart content type, we have overridden the method 
getCustomContentTypes() which adds the support for additional content types 
such as multipart/form-data , multipart/mixed .

2) Overridden the method " public ODataResponse createEntity(PostUriInfo 
uriInfo, InputStream content, String requestContentType, String contentType) " 
. Here the actual problem starts for us. This method is giving the parameter 
namely 'content' which is the request body . We didn't find any olingo API for 
parsing the content i.e request body ( of type multipart/form-data ) for 
getting the issue details and attachments out of it. Just for understanding If 
we see the REST , rest api provides some classes like MultipartBody , 
Attachment which gives us the attachments from request . Does Olingo provides 
any API  for getting attachments and other details out of 'content' request 
body which is there in createEntity() ? Please guide us whether the approach we 
are following is correct for handling the use cases i have mentioned ? Is 
Olingo missing the API for handling the attachments ?

Thanks



> Attachments support in olingo
> -----------------------------
>
>                 Key: OLINGO-662
>                 URL: https://issues.apache.org/jira/browse/OLINGO-662
>             Project: Olingo
>          Issue Type: Bug
>          Components: MISC, odata2-annotation, odata2-core, odata4-server
>    Affects Versions: V2 2.0.3
>            Reporter: Prashanth
>            Assignee: Christian Amend
>            Priority: Blocker
>              Labels: attachments
>
> This question is about the support for attachments uploading and downloading 
> via Olingo Service ( Olingo V2 2.0.3 ). I have gone the olingo docs but 
> didn't find any clue on how to provide support for uploading and downloading 
> of attachments using olingo . 
> Does olingo supports this functionality ? If olingo supports , how to 
> implements this ? 
> Following are some basics which i came to know by debugging the core library :
> -> Media type support : We can provide support for custom content types by 
> overriding the method getCustomContentTypes() in processor class. 
> -> Implementation : we can implement createEntity as following in processor 
> class :
> @Override
>       public ODataResponse createEntity(PostUriInfo uriInfo, InputStream 
> content, 
>       String requestContentType, String contentType) throws ODataException { 
> ... } 
>       
>       But here content is giving the requestBody , not actual file/attachment.
> Note : Here the support for attachments means - ex : in case of Rest , CXF 
> provides some api which can be seen in following snippet :
>       @POST
>       @Consumes( {MediaType.MULTIPART_FORM_DATA })
>       @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
>       public Response create(@Context HttpHeaders httpHeaders, @Context 
> UriInfo uriInfo,
>                       MultipartBody multipartBody)
> Here @Consumes media type provides consumption of multipart formdata and 
> MultipartBody parameter can give us the attachments. 
> Similar to above , Does Olingo V2 2.0.3 provides any API ?How can we 
> implement the support for attachments in Olingo V2 2.0.3 ? Please share us an 
> example !



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to