1

So far I have developed a server for a chat application using the Twisted framework and I am having a hard time trying to figure out how to implement storing a certain person's photo.

My first idea was that I can store the image locally[is this the best approach] and process it so but as I said before I can't figure out how to parse the photo.What I mean is how to send it to the server?

The photo should be selected from the client[iOS app] and sent to the server but as I said I don't understand how it will work.

Should I add something in the dataReceived or should I do something else?

What I did so far

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()

Any advices or ideas will be really helpful to me.

tudoricc
  • 709
  • 1
  • 12
  • 31

1 Answers1

1

solution might be:

  1. convert the image into blob or binary format and send to server.
  2. there again you can convert it original format
sundar nataraj
  • 8,524
  • 2
  • 34
  • 46
  • wow.I have to try this.but the blob/binary object will be parsed as a string? – tudoricc Sep 09 '14 at 07:26
  • @tudoricc http://stackoverflow.com/questions/16448925/twisted-image-transfer-from-client-to-server-gives-bad-format-error this link might be useful – sundar nataraj Sep 09 '14 at 07:27
  • So is it okay to assume that you pass the binary object as string and then just write it? using the 'wb' attribute? – tudoricc Sep 09 '14 at 08:25