QHttpMultiPart Qt 4.8.0, 4.8.1 - HowTo workaround Bug? (UploadFile fails)

found a bug in causing problems QHttpMultiPart to download files

Here's the bug: https://bugreports.qt-project.org/browse/QTBUG-25429

the bug is corrected: https://codereview.qt-project.org/#change, 24142

but not in the Version of Qt comes with waterfalls

QHttpMultiPart missing a CRLF at the end after the deadline.

Any idea of solution?

added a few rooms to the Multipart and then make a Post

mNetworkAccessManager->post(request, mRequestMultipart);

have no idea how to add a CRLF to the Multipart and want to avoid building complex MultiPart manually

GOD

See also this thread: http://supportforums.blackberry.com/t5/Cascades-Development/JAX-RS-vs-Qt-Multipart-Formdata/td-p/200...

I finally got by downloading a picture and other settings.

QString fn = QDir::currentPath() + "/app/native/assets/images/icon.png";

QNetworkAccessManager* netManager = new QNetworkAccessManager();
if (!netManager)
{
    qDebug() << "Unable to create QNetworkAccessManager!";
    emit complete("Unable to create QNetworkAccessManager!", false);
    return;
}

QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);

QHttpPart commentPart;
commentPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"comment\""));
commentPart.setBody("Comment goes here");

QHttpPart namePart;
namePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"name\""));
namePart.setBody("Name goes here");

QHttpPart imagePart;
imagePart.setHeader(QNetworkRequest::ContentTypeHeader, "image/png");
imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"image\"; filename=\"icon.png\""));

QFile *file = new QFile(fn);
file->open(QIODevice::ReadOnly);
imagePart.setBodyDevice(file);
file->setParent(multiPart);

multiPart->append(commentPart);
multiPart->append(namePart);
multiPart->append(blankImagePart);
multiPart->append(sectionPart);
multiPart->append(latPart);
multiPart->append(lonPart);
multiPart->append(imagePart);

QString queryUri = "http://your.urlhere.com";
QUrl url(queryUri);

QNetworkRequest req(url);

QNetworkReply* ipReply = netManager->post(req, multiPart);
connect(ipReply, SIGNAL(finished()), this, SLOT(commentDataReceived()));

Tags: BlackBerry Developers

Similar Questions

  • Problem with header and QNetworkAccessManager

    I'm having some trouble with authentication.

    According to the documentation imgur , simply use the following for anonymous use:

    Authorization: Client-ID YOUR_CLIENT_ID
    

    That has worked well when I was in QML, I simply used the following with XMLHttpRequest

    xmlhttp.setRequestHeader("Authorization", "Client-ID myclientid...");
    

    Now, I'm trying to download the image within c ++ and am getting error of authentication. I've tried several things, including

    QNetworkAccessManager* netManager = new QNetworkAccessManager();
    QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
    ...
    QHttpPart authPart;
    authPart.setRawHeader("Authorization","Client-ID myclientid..");
    ...
    multiPart->append(authPart);
    ...
    QNetworkReply* ipReply = netManager->post(req, multiPart);
    

    And I'm not sure of what hurts me, but he just keeps return this

    {"data":{"error":"Authentication required","request":"\/3\/upload","method":"POST"},"success":false,"status":401}
    

    Just use setRawHeader as suggested simon_hain.

    That's what I use for my library Imgur QtC ++

    QNetworkRequest request;
    request.setRawHeader("Authorization",  "Client-ID YOU_CLIENT_ID");
    
  • Download of images cascading bb10?

    Hello. Can someone give me the code for sending images to the server by using the post with code aside method php server. I tried the link following, but without success

    https://developer.BlackBerry.com/Cascades/reference/qhttpmultipart.html),

    Thank you

    Finally, I found the solution here...

    http://www.QtForum.org/article/31597/problems-with-uploading-big-file.html

  • JAX - RS vs Qt (Multipart Formdata)

    Maybe someone has an idea what I am doing wrong.

    I need to set up connections to the server for stunts and so far everything works fine.

    applications work for JSON and flows downloads

    the only problem still downloads a file on the server

    Here is a Java Code existing for Jax - RS com.sun.jersey

    FormDataMultiPart f = new FormDataMultiPart();
    f.field("token", this.token);
    f.field("file_length", "" + length);
    f.field("group_pk", "" + groupPk);
    f.field("log_uc", this.username);
    f.field("comment", comment);
    f.field("expiration_date", "");
    f.field("parent_path", parentPath);
    f.field("overwrite", (overwrite ? "1" : "0"));
    f.bodyPart(new StreamDataBodyPart("file_attachment", is, name));
    

    and here is my stunts/Qt-Code

    mRequestMultipart = new QHttpMultiPart(QHttpMultiPart::FormDataType, this);
    fileLengthPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form.data; name=\"file_length\""));
    fileLengthPart.setBody(QString::number(mFileLength).toUtf8());
    mRequestMultipart->append(fileLengthPart);
    groupPkPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form.data; name=\"group_pk\""));
    groupPkPart.setBody(QString::number(mGroupPk).toUtf8());
    mRequestMultipart->append(groupPkPart);
    parentPathPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form.data; name=\"parent_path\""));
    parentPathPart.setBody(mParentPath.toUtf8());
    mRequestMultipart->append(parentPathPart);
    commentPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form.data; name=\"comment\""));
    commentPart.setBody(mComment.toUtf8());
    mRequestMultipart->append(commentPart);
    logUcPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form.data; name=\"log_uc\""));
    logUcPart.setBody(mUser.toUtf8());
    mRequestMultipart->append(logUcPart);
    expirationDatePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form.data; name=\"expiration_date\""));
    expirationDatePart.setBody("");
    mRequestMultipart->append(expirationDatePart);
    tokenPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form.data; name=\"token\""));
    tokenPart.setBody(mToken.toUtf8());
    mRequestMultipart->append(tokenPart);
    overWritePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form.data; name=\"overwrite\""));
    overWritePart.setBody(QString::number(0).toUtf8());
    mRequestMultipart->append(overWritePart);fileAttachementPart.setHeader(QNetworkRequest::ContentTypeHeader, "application/octet-stream");
    fileAttachementPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form.data; name=\"file_attachment\"; filename=\""+mFileName+"\""));
    fileAttachementPart.setBodyDevice(mFileToUpload);
    mRequestMultipart->append(fileAttachementPart);
    

    This is the header

    request.setRawHeader("Accept", "application/json");
    request.setHeader(QNetworkRequest::ContentTypeHeader, "multipart/form-data");
    

    Server always replying 'Bad Request'

    think I forgot something. perhaps part of an attachment file is the problem?

    edited: added ContentTypeHeader and file name in fileAttachmentPart, but still no luck

    found the reason: a bug in Qt:

    https://bugreports.Qt-project.org/browse/QTBUG-25429

  • MacBook Pro display problem

    Hello members of the community.

    As of recently, I have noticed some glitches when feeding on my MacBook or awakened from his sleep.

    The colors are distorted, usually with pink, green, or yellow blobs. Blobs cannot entirely replace the colors, they appear to be contained in a element would normally be. For example. the menu bar will be partially pink and white, but pink does not leave the menu bar in this area, and the Office has green lines on it.

    I tried to take a screenshot, but the problem resolves in about 20 seconds, but it's a recurring problem.

    It happens when I wake up, connection or not. I had also certain powers serious and problems of performance, such that my MagSafe LED would not illuminate when plugged on rare occasions, fan could turn unnecessarily, graphics performance were SUPER slow, and the health of my battery was running out quickly. I actually ran a report on the system at 2 different times and my quality of full load is depleting of 1.2% per charge cycle, which is very worrying. I went from 6281 mAh mAh 6138 maximum capacity after two cycles of load. I'm tracking closely it because at this rate, my battery will survive only at load cycles about 150 instead of the 1000 expected, gives me the idea that this could very well be a bad battery. The computer is also warm to the touch while you sleep, not connected to the power supply. I NAP active but even taking into account should not be hotter my iPhone did the same thing.

    I have reset the SMC, and it solved a couple of problems. The charger works fine now and my performance improved considerably (which made me feel better, either it is a high-performance laptop, a 11-inch MacBook Air should not he surpass), and battery life has improved. I feel even if it uses a lot of power in his sleep. Maybe I need to turn off the NAP and see if that makes a difference. The graphic bug still persists however, and I don't have enough time to see if the max battery is depleting again.

    In regards to the bug, is there something that can be done? Basically, I want to assure you that I took all appropriate measures or if someone else has this problem to see if it can be software related instead of my computer.

    I have the entry level MacBook Pro with the retina, last generation.

    Any constructive contribution welcome!

    See you soon.

    -adreaux

    Hello bernardn753,

    After reviewing your post, it seems that you are having problems with the screen showing strange things on it. Looks like you already have a troubleshooting. I recommend you read this article, as reset NVRAM would be to reset your screen resolution settings that should help.

    How to reset the NVRAM on your Mac.

    Thank you for using communities of Apple Support. Good day.

  • Google Chrome won't quit

    I have the same material but with MacOS Sierra.

    Version 52.0.2743.82 (64-bit)
    Update failed (error: 11) Error Details:
    
    KSLockFile unable to open() lock file. [com.google.UpdateEngine.CommonErrorDomain:602 - '/Library/Google/GoogleSoftwareUpdate/TicketStore/Keystone.ticketstore.lock' - 'KSLockFile.m:431'] (The operation couldn’t be completed. Permission denied [NSPOSIXErrorDomain:13]) KSKeyedPersistentStore lock file error. [com.google.UpdateEngine.CommonErrorDomain:502 - '/Library/Google/GoogleSoftwareUpdate/TicketStore/Keystone.ticketstore.lock' - 'KSKeyedPersistentStore.m:329'] (KSLockFile unable to open() lock file. - '/Library/Google/GoogleSoftwareUpdate/TicketStore/Keystone.ticketstore.lock' [com.google.UpdateEngine.CommonErrorDomain:602]) KSPersistentTicketStore could not store ticket. (productID: com.google.Chrome) [com.google.UpdateEngine.CoreErrorDomain:1051 - '/Library/Google/GoogleSoftwareUpdate/TicketStore/Keystone.ticketstore'] (KSKeyedPersistentStore lock file error. - '/Library/Google/GoogleSoftwareUpdate/TicketStore/Keystone.ticketstore.lock' [com.google.UpdateEngine.CommonErrorDomain:502]) KSOmahaServer cannot save the updated ticket: '<KSTicket:0x51f820 productID=com.google.Chrome version=44.0.2403.157 xc=<KSPathExistenceChecker:0x50b620 path=/Applications/Google Chrome.app> serverType=Omaha url=https://tools.google.com/service/update2 creationDate=2012-05-18 22:28:01 tagPath=/Applications/Google Chrome.app/Contents/Info.plist tagKey=KSChannelID brandPath=/Library/Google/Google Chrome Brand.plist brandKey=KSBrandID versionPath=/Applications/Google Chrome.app/Contents/Info.plist versionKey=KSVersion cohort=1:1y5: cohortName=Stable >' (productID: com.google.Chrome) [com.google.UpdateEngine.CoreErrorDomain:602 - 'https://tools.google.com/service/update2'] (KSPersistentTicketStore could not store ticket. - '/Library/Google/GoogleSoftwareUpdate/TicketStore/Keystone.ticketstore' [com.google.UpdateEngine.CoreErrorDomain:1051])
    

    Click on high black Apple left and choose "force quit."

    Looks like it would be wise to reinstall Chrome, as it may not be updated when you updated to Sierra.

  • iPhone 7 more buttons outside does not

    I've had my iPhone 7 + for about 2 weeks now. Every once in awhile all buttons outside to stop, volume up/down, power, home. The home button will still record and push and give the sensation of taptic and touchID works. The phone itself still works and I can answer texts and which do not use notifications.

    The couple spent time he did, he came upon her in about 4-5 minutes, however it was about half an hour and still nothing. I want to restart my phone, but the switch does not work.

    Has anyone seen this issue or know how to fix?

    Thanks in advance.

    I just experienced the same problem on my iPhone 7, I think it's a bug in iOS, but I am using iOS 10.0.2. Power + button low Volume allowed me to turn it off then turn it back on... Apple please fix this bug!

  • The screen add people faces a (~ 1600) much just show as squares of white, grey

    Hello

    I was going through my photo library (running 2.0 on Sierra Photos) cleaning and marking of the people. I got far just about every face on the left is a square white, gray. If I add this person, the area where the image would be just rotates the circle of progress.

    Any idea on what is happening? I really miss the ability in iPhoto in order to have a Smart Album based on a photograph with a person "without name".

    Thank you, Tim

    That is a disused here bug that if you click on the x to remove a face, you end up with a tile empty - I hope that this will be fixed in a future Apple 9tell on the bug to improve its priority - http://www.apple.com/feedback/photos.html of output) and I hope that the patch will fix these old problems as well as properly - not advancing It is better to stop the removal of the faces until this problem is corrected

    LN

  • Uninstall software update Apple says error in seller contact package package unstaller

    Try to get itunes working to make a backup of my faulty iphone before repair.

    First-itunes does not start says error. I'm trying to fix it, who said success but same error when you try to start it.

    Then uninstall completely worked. Then reinstall that seemed to be over except for a message "an older version of Apple software update already exists" then he went down and install itunes apparently had not been completed.

    Then I try to remove the update from the apple software and executed by an error in the installation program - it says there is an error in the installation and contact the supplier of the installation package. Same error if I run the uninstall command line program.

    Try to repair the Apple Software Update of programs & features Control Panel and then try to update iTunes again.

    For general advice, see troubleshooting problems with iTunes for Windows updates.

    The steps described in the second case are a guide to remove everything related to iTunes and then rebuild what is often a good starting point, unless the symptoms indicate a more specific approach.

    Review the other boxes and other support documents list to the bottom of the page, in case one of them applies.

    The more information box has direct links with the current and recent if you have problems to download, must revert to an older version or want to try the version of iTunes for Windows (64-bit - for older video cards) as a workaround for problems with installation or operation, or compatibility with third-party software.

    Backups of your library and device should be affected by these measures but there are links to backup and recovery advice there.

    TT2

  • I've never done a Time Machine backup and I have upgraded to iOS Sierra. Help!

    I'm a fool. After owning my Macbook for 5 years, I failed to make a single Time Machine backup. I just saved my essential to an external hard drive. I have upgraded to iOS Sierra. Big mistake. I want to go back to iOS Capitan, but it does not seem possible. Now, my external hard drive is wiped clean (things are dark). What are my options? If I'm stuck with Sierra?

    If you have downloaded El Capitan, it should always be available in your purchases. Now, you will need to make a backup to backup your personal files.

  • Can I combine 3 accounts 1 Apple?

    I've made several purchases (apps, music, movies) from the iTunes store.  Unfortunately for me, until I realized it was a problem, I made the purchase of three different accounts.  I asked once before and I was told that it was impossible to combine accounts.  The situation has changed, or is there a reasonable workaround?

    If it proves impossible, maybe set up a family sharing and the other two ghosts that is your family.

  • macOS bug Sierra - Possible? (Terminal)

    I use the Terminal Df-h command to find the percentage of used space on the hard drive of my Mac, and I've noticed that since the upgrade to Mac OS Sierra; It came out that I used 0% (which may not be true); I was wondering could this be a bug and this is the case with anyone else?

    In fact, it is show you used 6% of disk space. 0 percent at the end relates the number of inodes that are used (data structures that manage the different metadata). Because you have so few files you are not yet using 1% of inodes, so he says always 0% are used.

    So, no, no bug

  • Calendar Apple App Bug frozen works only with iOS 10 update grrr

    Since I updated to iOS 10 (more more later than 10.2, etc.), everything was not too bad except THE APPLE CALENDAR app, its deiving me crazy when I click on the app it's like it freezes and past shift x 50 mode still something to do with the calendar app will cause either a frozen or a black screen or white and then crashed ack to main menu. Sometimes it will allow me to create but will be trolling with typing and finally crashed or not even save it... Please HELP I am sure what else to do, I tried to download google calendar and which seemed to have something of bug he loves too then something happens. And I tried to delete it and download it again, / force delivery, nothing has changed

    Hi there calsparks!

    Thank you for bringing your question on the calendar of freezing and trolling since the update to iOS 10 on your iPhone for Apple Support communities.  I rely on the calendar to keep my life organized, so I'm happy to help you resolve this issue today.

    Looks like you did a few good troubleshooting by force to leave the app, force to restart the iPhone and deleting and reinstalling the application calendar.  At this stage my next recommendation would be to backup your iPhone, then erase and restore your iPhone as a new device, then test calendar to see if it behaves correctly, and then restore your backup.

    The backup of your iPhone, iPad and iPod touch

    Use iTunes on your Mac or PC to restore your iPhone, iPad or iPod to factory settings

    Restore your iPhone, iPad or iPod touch from a backup

    Have a great day!

  • Automator leave all

    I want a script to close all open applications and empty the trash.

    Applications and Finder behave differently.

    Automator "Utilities" options appear the best result, so I'm focused there.

    I am able to stop all applications, but the Finder is stubborn

    I can close the Finder components as a group within Automator, but combining this group with the group "Close all Applications" The Automator scripts fails to close the components Finder (Finder, Get info and inspector window).

    Here's what I have so far.

    Group 1: on his own closing everything except the Finder stuff.

    Utilities > quit all applications

    Quit all applications

    Group 2: this group works well.

    Utilities > run AppleScript

    the term {parameters}

    Tell application "Finder".

    empty the trash

    tell the end

    delay 1

    Back entrance

    end of race

    Group 3: run on its own that works, but not with "quit all Applications.

    Utilities > run AppleScript

    the term {parameters}

    Tell application "Finder".

    activate

    quit smoking

    delay 3

    Tell application "Finder".

    activate

    tell the end

    tell the end

    Back entrance

    end of race

    Group 4: it works on its own for Finder stuff, but does not work with other groups.

    Utilities > run Script Shell

    CAT

    osascript-e 'tell application "Finder" to quit smoking.

    I noticed that sometimes the AppleScript works, and a second later it stops working.

    For now, I found a way to make it work. Automator works great Finder asking you to empty the trash. Then I dropped the trash from Group 2 to group 4, the bottom of the collection of Automator. Now it works... for now...

    Group 1: Utilities > quit all applications

    Quit all applications

    Group 2: Utilities > run AppleScript

    the term {parameters}

    Tell application "Finder".

    activate

    quit smoking

    delay 3

    Tell application "Finder".

    activate

    tell the end

    tell the end

    Back entrance

    end of race

    Group 3: Utilities > run Script Shell

    CAT

    osascript-e 'tell application "Finder" to quit smoking.


    Group 4: Utilities > run AppleScript

    the term {parameters}

    Tell application "Finder".

    empty the trash

    tell the end

    delay 1

    Back entrance

    end of race


    If anyone knows why this command works, an explanation would be appreciated.

  • iTunes and Blackberry link conflicts

    Hi, link to Blackberry stopped working after the last update of iTunes in Windows 10.

    I made Blackberry suggest workaround solution, as follows:

    "Rename the file of l iTunesPrefs.xmand restart the BlackBerry link application.

    Please note: Completing the steps below may have harmful effects on the functionality of iTunes. For more information, contact Apple support.

    To rename the iTunesPrefs.xml;

    1. Turn on the Show hidden folders and files
    2. Go to \AppData\Roaming\Apple Computer\iTunes\ < username > C:\Users\
    3. The XML in the file iTunesPrefs and rename it to iTunesPrefs.old

    Once finished, he recommends to disable display the hidden files and folders. »


    My question is, how will this affect iTunes functionality, or not at all?



    Rename iTunesPrefs.xml will reset various settings in iTunes. If your library is < user music > \iTunes default path and you have the options to keep... and copy... enabled, you may not notice a change, but the parameters that will have been reset include the active library, media folder file, sharing of XML, the import settings, etc. Check through each tab in Edit > Preferences to see if there's anything to change the way that you had it before.

    TT2

Maybe you are looking for

  • Firefox crashes or freezes when opened. Help, please!

    My firefox does not open. I have been using Firefox without problems for years until yesterday. I have a Mac OS X 10.10.3. Whenever I open Firefox, it immediately crashes or freezes. I have to go to my dock to "force quit" Firefox. I tried to uninsta

  • 19.0.2 'problem upgrade '.

    I leave Firefox 'upgrade' 19.0.2 on my Windows 7 laptop today. It is even impossible to load a page. It is all display tabs without loaded content. Displaying an address or a search does nothing, the browser ignores just my request. There is nothing

  • Automatic graphics card switching

    How can I activate the graphic card automated switching, where the system chooses to use the Nvidia card or integrated graphics card Intel? I recently bought a Lenovo Y580 and installed a 120 GB SSD with a new installation of Windows 7. I downloaded

  • Difficulty accessing basic programs

    I have problems to access the Basic programs, such as accessories, in the start menu. When I click on start > all programs > Accessories > entertainment, for example, I get "(empty)." Even for Microsoft Office > Microsoft Word. But if I search the pr

  • home network security - can't get through all the requirments

    original title: home network security Have set up a home network on linksys router, I have passwords, but can not access to network from a laptop computer, domain name, password and logon of the user are needed I have router username, router password