ios – Swift URL Session Response will get corrupted when utilizing ‘&’ image

[ad_1]

I’m growing iOS app, I’m utilizing URL Session methodology for make API calls. Api response provides one property which accommodates AWS s3 hyperlink for pdf doc.

What ought to occur:
So on this app, I’m retrieving a PDF doc from the server to view within the app, so within the GET URL that I am sending will give a response of an entry hyperlink of the pdf doc generated by means of AWS S3.

What is occurring now:

Doc identify: Doc/sdd3343-sfnf0asdnd0UserB&ServiceLetter.pdf (discover there’s an ‘&’ signal)

Within the android and Swagger utility, this GET URL is working excellent on any circumstances.
however within the iOS version- within the URL session, when ever when there’s a ‘&’ signal contained in the doc’s identify, the responding entry hyperlink will get corrupted.

Now in Android and Swagger, once we are accessing the identical doc, it really works completely, however for iOS it would not.

URL that does not work on iOS however that works in Android and Swagger:

https://domainName/api/FileUpload/GetDocumentUrl?S3Key=**Doc/sdd3343-sfnf0asdnd0UserB&ServiceLetter.pdf**&fileCategory=2&userId=9888900000

Above url having parameter identify known as ‘S3Key’ worth is Doc/sdd3343 sfnf0asdnd0UserB&ServiceLetter.pdf and it having an ampersand ‘&’ image in center of the identify.

iOS response for the above URL:

{"success":true,"response":"https://samplesite.s3.ap-southwest-2.amazonaws.com/Doc/sdd3343-sfnf0asdnd0UserB?X-Amz-Expires=3600&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAWEWNDEFIENS88NKWSWIULHKA/20221010/ap-southwest-2/s3/aws4_request&X-Amz-Date=20221010T011135Z&X-Amz-SignedHeaders=host&X-Amz-Signature=44cab95333c0b5e385959835948539845948023823483","error":null}

In right here you’ll be able to see the response which bought by the URL Session. However the reponse url physique lower off from ampersand image.

Present Response: /Doc/sdd3343-sfnf0asdnd0UserB?X-Amz-Expires=3600&X………

Anticipated Response: /Doc/sdd3343-sfnf0asdnd0UserB&ServiceLetter.pdf?X-Amz-Expires=3600&X………

The best way to clear up this URL Session drawback

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *