Re: REST-API: "content" Properties

"John P. Rouillard" <[email protected]>
Newsgroups gmane.comp.bug-tracking.roundup.devel
Message-ID <[email protected]>
Hi Ralf and Joseph:

In message <[email protected]>,
Joseph Myers writes:
>On Fri, 22 Mar 2019, Ralf Schlatterbeck wrote:
>
>> I honestly don't know what would happen if we attach the file as a byte
>> string in python3, if the json serializer can handle this.
>
>JSON (the format) does not support binary data (there are workarounds 
>people use such as base64-encoding binaries, but you need to know which 
>content properties are text and which are binary - which is information 
>the Roundup schema doesn't give you at present).

I think the schema has a type property for files. I see image/jpeg for
example in the default file content/type property.

Msgs however don't have any such header. However I think all msgs are
saved as text/plain utf8 encoding right? This may have issues with
using the tracker for Chinese or something however.

For content that is not text, I suggest returning:

"content" : {
  content-type: image/jpeg
  link: .../file/22/content
  id: 22
}

then the json call must include:

  accept: image/jpeg

when accessing the link. Otherwise the call returns 406 "not
acceptable" or whatever is returned if we try a rest call with an
unsupported accept type. So @verbose > 2 is no different from
@verbose=2.

I forget is @verbose=1 drops the link or not. If it does drop the link
it must still include the content-type field.

For text type @verbose > 2:

  "content": {
  	     id: 2
  	     content-type: text/plain
	     content:	"json blob of text"
	     link: .../msg/2		
	     }

For verbose < 2, only return the link, id and content-type and not content.

I don't think there is a way to return a multipart mime type, to a
json parser, but that is another way to possibly do this. So the first
part is json and the content fields somehow are references to the
second, third etc.  part of the multipart document. Again I don't
think this is possible in the REST framework if json (or xml) is
requested but ...

Thoughts?

--
				-- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.