将带格式的文本+图像发送到移动应用程序的最佳方法是什么 [英] What is the best way to send text+image with formatting to mobile application

查看:69
本文介绍了将带格式的文本+图像发送到移动应用程序的最佳方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好



我想为用户创建一个空间,以便在移动应用程序的个人资料部分中添加一些关于他的事件或信息。



为用户创建此功能的最佳方法是什么?我应该如何将信息发送到移动应用程序。 用什么json格式?



用户功能:



- 他可以添加文字+图像+链接(URL,电子邮件,电话)

- 他可以将文本格式化为(粗体,斜体,下划线)

- 图片可能有字幕



注意:我只负责网络部分(前端和网络服务)



你的帮助是非常感谢。

解决方案

这个问题没有多大意义,真的,因为这完全取决于你的移动应用程序,因为你没有制定要求,也没有解释任何特定的问题。



好​​吧,对于格式化文本,您可以使用HTML标记来使用HTML或XML,只是为了节省您自己发明内容的时间。但HTML并不足够,因为你需要发送图像。图像不是以HTML格式发送的,它们是通过URL和单独的HTTP请求单独发送的,但您需要使用数据打包图像。图像应该是二进制数据(矢量图像除外,它可以使用SVG或XAML,基于XML的格式嵌入;但我怀疑你的意思是像素图像)。所以你必须在XML之上创建一个格式,将它与XML和/或HTML结合起来。



已经存在一种这样的格式:电子邮件格式。图像打包为单独的部分,您可以使用特殊的 URL方案cid:在邮件消息中引用它们。请参阅我过去的回答:发送带图片的HTML附件 [ ^ ]。br />


邮件消息格式的唯一问题是图像(以及使用不同MIME类型的许多其他类型的部分)在二进制文件上使用base-64格式,这需要更多空间(这是因为邮件消息格式基于纯文本)。所以你可以想到别的东西,比邮件消息格式复杂,但是你可以用二进制格式化图像。



此外,你需要开发一些应用层协议并在两端实现它。它可以在TCP之上实现,实现可以使用Java套接字。您也可以使用FTP等。请参阅:

https://en.wikipedia.org/wiki/Application_layer [< a href =https://en.wikipedia.org/wiki/Application_layertarget =_ blanktitle =New Window> ^ ],

https://docs.oracle.com/javase/tutorial/networking/sockets [ ^ ]。



< DD> -SA

Hello

I want to create a space for the user to add some events or information about him to be displayed in his profile section on the mobile application.

what is the best way to create this function for user and how should i send the information to the mobile app. "in what json format?"

The User function:

- He can add Text + Images + links( URL, Email, Phone)
- He Can Format the text As (Bold, Italic, Underline)
- Image May have Captions

Note: Im responsible for the web part only ( Front end and web service )

Your Help is appropriated thanks.

解决方案

The question makes little sense, really, because it all depends on your mobile application and because you did not formulate requirements and did not explain any particular problem.

Well, for formatted text, you can use HTML or XML using HTML markup, just to save time on inventing something on your own. But HTML along will not be enough, because you would need to send images. Images are not sent in HTML, they are sent separately, through URLs and separate HTTP requests, but you would need to pack images with your data. Images should be binary data (except vector images, which can be embedded using SVG or XAML, XML-based formats; but I suspect you mean pixel images). So you have to create a format on top of XML, to combine it with XML and/or HTML.

One such format already exists: e-mail message format. The images are packed as separate parts which you can reference inside the mail message using special URL scheme "cid:". Please see my past answer: Sending HTML attachment with images[^].

The only problem with mail message format is that images (and many other kind of parts using different MIME types) use base-64 format over the binary, which takes more space (this was done because mail message format is based on pure text). So you can think of something else, with less complexity than mail message format, but you could binary format for images.

Besides, you need to develop some application-layer protocol and implement it on both sides. It can be implemented on top of TCP and the implementation can use Java sockets. You can also use, for example, FTP. Please see:
https://en.wikipedia.org/wiki/Application_layer[^],
https://docs.oracle.com/javase/tutorial/networking/sockets[^].

—SA


这篇关于将带格式的文本+图像发送到移动应用程序的最佳方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆