Hello all,

I am currently developping for fun a "mobile webcam" in python, ie basically I am uploading a picture every 60 seconds to a server.

So far everything goes well, excepted for the fact that the picture that I send seems to reach only partially my server.
As you can see:
mobile webcam
The jpeg file is incomplete most of the time.

I've tried my python code on my computer's interpreter ( I only had to remove the "pys60 only" part, mostly GUI ) and there's no problem with the upload.

Is there a problem with my phone ? ( a Nokia 6680 ) Or is it a problem with the ISP parameters ? is there a way I can check what's wrong for sure ? And most important, how can I fix it !!

here's the python code I use ( the most relevant parts according to me ):
Code:
def post_image(cell_id, key, nom_fichier, contenu):
    BOUNDARY = '-------------UhUhUh------'
    CRLF = '\r\n'
    L = []
    L.append('--' + BOUNDARY)
    L.append('Content-Disposition: form-data; name="cellid"')
    L.append('')
    L.append(cell_id)
    L.append('--' + BOUNDARY)
    L.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (key, nom_fichier))
    L.append('Content-Type: image/jpeg')
    L.append('')
    L.append(contenu)
    L.append( '--' + BOUNDARY + '--' )
    L.append('')
    body = CRLF.join(L)
    content_type = 'multipart/form-data; boundary=%s' % BOUNDARY
    conn = httplib.HTTPConnection("pangcentury.free.fr")
    conn.putrequest('POST', '/mobileWebcam/mobileWebcam.php')
    conn.putheader('content-type', content_type)
    conn.putheader('content-length', str(len(body)))
    conn.endheaders()
    conn.send(body)
and

Code:
def run():
    global running, img, total_bytes_sent, max_bytes, direction, white_bal, expos, fl, IMEI
    while running and total_bytes_sent < max_bytes:
        if int( sysinfo.battery() ) < 2:
            logging(u"Attention, batterie trop faible !\nL'application va se terminer.")
            running = 0
        else:
            params = { 'mode':'RGB16', 'size': (640,480),
                       'flash':fl, 'zoom':0, 'exposure': expos,
                       'white_balance':white_bal, 'position':0
                       }
            img = apply(camera.take_photo, (), params)
            img = img.resize((160,120), keepaspect = 1 )
            if direction != '':
                img = img.transpose(direction)
            img.save("E:\\Images\\mobileWebcam.jpg")
            cellid = location.gsm_location()[3]
            cell_id = str(cellid)
            taille = os.path.getsize("E:\\Images\\mobileWebcam.jpg")
            fichier = open("E:\\Images\\mobileWebcam.jpg", 'rb')
            try:
                post_image(cell_id, 'image', 'nokia6680.jpg', fichier.read())
                total_bytes_sent += int(taille)
                truc = total_bytes_sent / 1024
                truc2 = unicode(truc)
                truc2 += u" ko envoyés au total"
                logging(truc2)
                countdown(60)
            except:
                logging(u"erreur dans l'envoi du fichier" )
                running = 0
            fichier.close()
    if total_bytes_sent > max_bytes:
        logging(u"maximum d'upload autorisé atteint." )
Oh and while I am at it, here's a likely bug I stumbled upon while coding this: it seems like you can't use the flash in camera.take_photo() if the picture size is (160,120). That's why I have to take the picture first in (640,480) and resize it.