Using ServiceStack to upload image files

旧巷老猫 提交于 2019-12-17 18:59:27

问题


We have a requirement to upload images using ServiceStack APIs.

I am aware of two possible ways:

1) Use JSON object to upload file (Using BASE64 string). 2) Use "multipart/form-data"

Is there any other way of uploading files using ServiceStack? Which is better in terms of best practices?


回答1:


The best way to upload files in ServiceStack is to just do a normal HTTP File upload see the source code for imgur.servicestack.net or file uploads in RestFiles for examples.

If you don't want to send multipart/form-data then use a binary format like Protocol Buffers support in ServiceStack and send byte[] to avoid the computational and payload overhead of encoding binary files in a text format.



来源:https://stackoverflow.com/questions/16475720/using-servicestack-to-upload-image-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!