Wiki

        case 5:

            // Upload d'image
            {
                QByteArray data;
                car = "";
                param1 = "";
                do {
                    param1 += car;
                    car = QString(clientConnection->read(1));
                } while (car != ";");
                taille = param1.toInt(&ok,10);

                while(taille != data.size()) {
                    if (clientConnection->waitForReadyRead(30000)) {
                        QByteArray temp = clientConnection->read(taille - data.size());
                        data.append(temp);
                    }
                }

                QImage image;
                image.loadFromData(data, "JPG");
                image.save("test.jpg");
                /*
                // Ajout de l'image dans la librairie
                imageLibraries = ImageLibraries::getInstance();
                imageLibraries->getLibrary(0)->addNode();
                */
            }
            break;

    @Override
    public void performUploadImage() {
        assert (img != null); // ASSERTION si l'image est vide, vérifier la
                                // fonction d'initialisation
        trame = "5" + img.size() + ";";

        out.write(trame);
        out.flush();
        try {
            s.getOutputStream().write(img.toByteArray());
            s.getOutputStream().flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }