python - 使用 Twisted 在服务器中存储图像

标签 python ios twisted twisted.client

到目前为止,我已经使用 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()

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

最佳答案

解决方案可能是:

  1. 将图像转换为blobbinary格式并发送到服务器。
  2. 你又可以把它转换成原来的格式

关于python - 使用 Twisted 在服务器中存储图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25738634/

相关文章:

python - 彻底使用管理员界面

ios - 使用 CCClippingNode 的屏幕截图 - cocos2d-iphone-2.1-beta4

python - 如何识别扭曲的客户端?

python - Twisted 的文档字符串中这些格式的含义是什么?

python - 连接到在(有时是虚拟化)Windows 计算机上运行的服务器时出现问题

python - py.test 在堆栈跟踪中打印出完整数据

python - 找不到 Django 包测试

python - 跳过文件的某些字节并返回内容

ios - Swift 无法导入 Obj-C 模块?

ios - 以编程方式更改 UIStackView 中 1 个 subview 的大小