0

I'm trying to print the Data which contains string and media (image) as part of multipart form-data. It does print text content but also dumps the jpg image which obviously goes into infinite dumping. Is it possible to print something meaningful from this Data so that media (image) part doesn't get printed?

I was thinking if it is possible to just print, by writing a custom function, text content from it and ignore image part?

print(String(decoding: request.httpBody!, as: UTF8.self))

Snippet of print

...

Content-Disposition: form-data; name="image"; filename="IMG_0111.HEIC" Content-Type: image/jpeg

����JFIF,,AMPF��-sExifMM*V^(�if�HH�0221��0100����Ф(,KHH����x�"��
.....

Dan
  • 475
  • 9
  • 26
  • What (exact) output would you consider correct here? I mean, precisely what letters would you want to show up on the screen if it did what you wanted? – Rob Napier Jan 29 '19 at 18:21
  • I've text values in multipart data in addition to image. I want to see the text content before the image data starts printing. – Dan Jan 29 '19 at 18:44
  • So it sounds like you want to parse multipart form data and output some portions of it? Like https://stackoverflow.com/questions/22095186/parse-multipart-response-for-image-download-in-ios? (How did you create this `request`?) Again, I suggest you rephrase your question as *precisely* what you would want the output to look like. It's not clear from the question what "the text content" is. There doesn't seem to be any text content in your question. Provide the exact input and the exact output you're expecting. – Rob Napier Jan 29 '19 at 19:29
  • @Dan how to print it? did you get the way?? please share – A.s.ALI Jun 03 '21 at 10:45

1 Answers1

0

Print function https://developer.apple.com/documentation/swift/1541053-print as Apple says:

Writes the textual representations of the given items into the standard output.

if you want to check what's the image in the httpBody you'll must to use a UIImageView and show it on it.

Camilo Lopez
  • 166
  • 5