Project

General

Profile

Actions

Support #2023

closed
GM WD

how to perform multipart response

Support #2023: how to perform multipart response

Added by go mac about 13 years ago. Updated about 13 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
07/11/2013
Due date:
% Done:

0%

Estimated time:

Description

Hi,

I have created a RESTful web service that processes a multipart request from an iPhone app, which includes an image and some text. I can extract my payload using getParameter and getUploadedFile.

I can return a response containing an image. The only way I could get it to work was using WStreamResource. This is what I do to return the image (the image file name is in picker*->fileName*.c_str(). My resource class has a parent of WStreamResource

// load image into stream
std::ifstream outImage(picker*->fileName*.c_str(), std::ios::in | std::ios::binary);

// stream response
handleRequestPiecewise(request, response, outImage);

Earlier attempts used WResource but streaming the image file to response.out() didn't seem to work, i.e. the entire file didn't seem to be getting sent in the response.

I would now like the response to be multipart and return, not just the image, but some text as well. How can I load up the multipart response?

regards,
Gordon

WD Updated by Wim Dumon about 13 years ago Actions #1

  • Status changed from New to Resolved

Hello Gordon,

There's currently no provision to support this from a WResource, so you will have to implement the multipart mechanism yourself (which is not too difficult).

We did implement multipart support in our email classes, they can serve as inspiration but the implementation is probably too complex for your case (7-bit ascii and different mail client behaviour...). Maybe take a look at the examples on wikipedia? http://en.wikipedia.org/wiki/MIME#Multipart_messages

BR,
Wim.

KD Updated by Koen Deforche about 13 years ago Actions #2

  • Assignee set to Wim Dumon

KD Updated by Koen Deforche about 13 years ago Actions #3

  • Status changed from Resolved to Closed
  • Target version set to 3.3.1
Actions

Also available in: PDF Atom