【问题标题】:Store image in server using Twisted使用 Twisted 将图像存储在服务器中
【发布时间】:2014-09-09 07:10:00
【问题描述】:

到目前为止,我已经使用 Twisted 框架为聊天应用程序开发了一个服务器,但我很难弄清楚如何实现存储某个人的照片。

我的第一个想法是我可以将图像存储在本地[这是最好的方法]并处理它,但正如我之前所说,我无法弄清楚如何解析照片。我的意思是如何发送它到服务器?

应该从客户端[iOS应用]中选择照片并发送到服务器,但正如我所说,我不明白它是如何工作的。

我应该在 dataReceived 中添加一些内容还是应该执行其他操作?

到目前为止我做了什么

from twisted.internet import reactor
from twisted.internet.protocol import Factory , Protocol

class IphoneChat(Protocol):
  def connectionMade(self):
    self.factory.clients.append(self)
  def connectionLost(self , reason):
    self.factory.clients.remove(self)
  def dataReceived(self,data):
    #do a lot of processing which works

 factory = Factory()
 factory.protocol=IphoneChat
 factory.clients = []
 reactor.listenTCP(8023,factory)
 print "IPhone Chat server started"
 reactor.run()

任何建议或想法都会对我很有帮助。

【问题讨论】:

    标签: python ios twisted twisted.client


    【解决方案1】:

    解决方案可能是:

    1. 将图片转换为blobbinary格式并发送到服务器。
    2. 您可以再次将其转换为原始格式

    【讨论】:

    • 哇。我必须试试这个。但是 blob/binary 对象将被解析为字符串?
    • @tudoricc stackoverflow.com/questions/16448925/… 这个链接可能有用
    • 那么可以假设您将二进制对象作为字符串传递然后直接编写它吗?使用“wb”属性?
    猜你喜欢
    • 1970-01-01
    • 2017-08-06
    • 2016-07-30
    • 1970-01-01
    • 1970-01-01
    • 2019-03-17
    • 2015-01-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多