如何通过http上传文件到网站? (黑莓)
我需要通过http或ftp将文件上传到blackberry jde中的网站。
I need to upload a file through http or ftp to the website in blackberry jde.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
高级视图:您从 打开一个 OutputStream HttpConnection 并将数据写入该输出流。主要问题是选择使用哪个网络连接(我建议查看 这个,除非您使用的是内置类似功能的操作系统 5.0)。至于通过 FTP 上传会有些困难,因为 BlackBerry API 不支持内置 FTP,因此您必须考虑使用 SocketConnection 并自己实现 FTP 的一部分。
这里有一些代码可以帮助您开始:
当然,您需要处理异常、关闭流、检查是否已成功上传等
High level view: You open an OutputStream from an HttpConnection and write your data into that output stream. The main problem is going to be choosing which network connection to use (I recommend looking at this, unless you're on OS 5.0 which has a similar feature built in). As to uploading through FTP that will be somewhat more difficult as there is no support for FTP built into the BlackBerry API instead you'll have to look at using a SocketConnection and implementing part of FTP yourself.
Here's some code to get you started:
Of course you'll need to deal with exceptions, close the streams, check that it was uploaded successfully, etc