def server_shouldHandlePutRequest_(self, server, requestheaders): #print "Incoming file:", requestHeaders.valueForNameHeader() self.delegate = _macutil.BBFileLikeObjectWriter.alloc( ).initWithFileLikeObject_(self.__fileobject) outstream = BBStreamingOutputStream.alloc().initWithDelegate_( self.delegate) outstream.open() return outstream
def get(self, headers, fileobj): if not hasattr(fileobj, "write"): raise TypeError("file-like object must have write() method") self.__checkconnected() self.__reset() headerset = _headersdicttoset(headers) delegate = _macutil.BBFileLikeObjectWriter.alloc().initWithFileLikeObject_(fileobj) outstream = BBStreamingOutputStream.alloc().initWithDelegate_(delegate) outstream.open() r = self.__client.sendGetRequestWithHeaders_writeToStream_( headerset, outstream) if r != _kOBEXSuccess: raise OBEXError(r, "error starting Get request (%s)" % errdesc(r)) _macutil.waituntil(self._done) if self.__error != _kOBEXSuccess: raise OBEXError(self.__error, "error during Get request (%s)" % errdesc(self.__error)) return self.__getresponse()
def server_shouldHandlePutRequest_(self, server, requestheaders): #print "Incoming file:", requestHeaders.valueForNameHeader() self.delegate = _macutil.BBFileLikeObjectWriter.alloc().initWithFileLikeObject_(self.__fileobject) outstream = BBStreamingOutputStream.alloc().initWithDelegate_(self.delegate) outstream.open() return outstream