Upload ios image with qt

  • Hi , i use qt 5.3 on mac. I 've accessed to ios gallery with UIImagePickerController and i've get selected image url like this:
    Now i want to upload this image on server. I converted the url to QString and called myUploadFunction(QString path). This function gets a path(that is a real path of image on device), creates a QFile, reads data from the file and posts data:
    QFile *file = new QFile(path);
    QByteArray fileData = file->readAll();

    I know the upload method works on android and windows desktop. But in ios,i think i can not create a file from the image url (assets-library://asset/asset.jpg?id=..&ext=jpg). I need image actual path in ios. how can i get an image real path from it's url on ios to upload it?
    Thanks in advance

  • I found a way to get an image file real path on ios from "here":https://github.com/questbeat/QBImagePickerController/issues/6
    path on simulator:
    file:///Users/mrsranjkesh/Library/Application Simulator/iPhone Simulator/7.0.3/Applications/9CB32.../Document/Koala.jpg
    When i give this path to my upload file, I get this error: QIODevice::read Device not open. When i tested file.exist(), i got "false"
    please reply. Thanks

  • Did you manage to solve your problem.

    I'm facing the same problem. When I use FileDialog, fileUrl looks like "file:assets-library:/asset/asset.JPG%3Fid=78FD7629-DBEE-4279-ACAE-A54F1FEB9B58&ext=JPG" and I cannot assign this as an image source.

  • Qt Champions 2016

    @ahmad88me Did you tried to use uri like "assets-library:/asset/asset.JPG%3Fid=78FD7629-DBEE-4279-ACAE-A54F1FEB9B58&ext=JPG" ?

  • @benlau Yes, still doesn't work

  • Hello i've got the same problem :(
    Did you resolve it ?

  • Hello,
    Same bug for me.

    There is no need to have a beautifull picture picker if we can't upload one of those pictures.

    One thing I don't understand :
    QML Image is able to understand a path like "file:assets-library:/asset/asset.JPG..."
    But neither QFile, nor QFileInfo, nor QImage can do that.
    Do you have an idea why ?

  • Guys, I found a solution :

    QString path("file:assets-library:/asset/asset.JPG...");
    QUrl url(path);
    path = url.toLocalFile();

  • @Vi67 said:

    QString path("file:assets-library:/asset/asset.JPG...");
    QUrl url(path);
    path = url.toLocalFile();

    Thanks man, you saved me!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.