Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when i upload file using backgroundUpload, the body inside the response is empty [ios] #263

Open
segun-flexible opened this issue Jan 5, 2024 · 3 comments

Comments

@segun-flexible
Copy link

here is the code am using to upload file to my backend, and am responding json back from the backend like this res.json({status: true, message :"File Uploaded"})

backgroundUpload( ${BASE_URL}/api/user/upload-media?id=${result.id}, file.uri, { fieldName: 'medias', mimeType: file.mediaType == "photo" ? "image/png" : mime.getType(file.uri), uploadType: UploadType.MULTIPART, httpMethod: 'POST', headers: { 'is_native_app': 'is_native_app', 'Content-Type': 'multipart/form-data', 'Authorization': Bearer ${token}` } }
).then((result => {
console.log(result, "ok")
const response = JSON.parse(result.body);

          if (response.status) dispatch(writtenAction.incrementWritten())
          else {
            dispatch(writtenAction.clearWritten())
            return openModal({
              title: "Something Went Wrong",
              sub: response.message,
              btnText: "Okay",
              headerImg: require("../../assets/error.png")
            })
          }
        })).catch(err => console.log(err, "error here"))
      }`

here is the response on Android
Object { "body": "{\"status\":true,\"message\":\"File Uploaded\"}", "headers": Object { "Access-Control-Allow-Credentials": "true", "Access-Control-Allow-Origin": "*", "Connection": "keep-alive", "Content-Length": "41", "Content-Type": "application/json; charset=utf-8", "Date": "Fri, 05 Jan 2024 17:25:51 GMT", "ETag": "W/\"29-WcVpNPZgUZEDrIUCox0kVl9B85A\"", "Expect-CT": "max-age=0", "Keep-Alive": "timeout=5", "Referrer-Policy": "no-referrer", "Strict-Transport-Security": "max-age=15552000; includeSubDomains", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", "X-DNS-Prefetch-Control": "off", "X-Download-Options": "noopen", "X-Frame-Options": "SAMEORIGIN", "X-Permitted-Cross-Domain-Policies": "none", "X-XSS-Protection": "0", }, "status": 200, }

but on ios the body is not showing, its empty

Object { "body": "", "headers": Object { "Access-Control-Allow-Credentials": "true", "Access-Control-Allow-Origin": "*", "Connection": "keep-alive", "Content-Length": "41", "Content-Type": "text/html; charset=utf-8", "Date": "Fri, 05 Jan 2024 17:56:57 GMT", "Etag": "W/\"29-WcVpNPZgUZEDrIUCox0kVl9B85A\"", "Expect-CT": "max-age=0", "Keep-Alive": "timeout=5", "Referrer-Policy": "no-referrer", "Strict-Transport-Security": "max-age=15552000; includeSubDomains", "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", "X-DNS-Prefetch-Control": "off", "X-Download-Options": "noopen", "X-Frame-Options": "SAMEORIGIN", "X-Permitted-Cross-Domain-Policies": "none", "X-XSS-Protection": "0", }, "status": 200, }

as you can see the body is empty, which am not expecting that, it show the body on android but is not showing it on ios

@nikitapilgrim
Copy link

same

@husnain917
Copy link

I have same issue on IOS android working fine.

@raghsahu
Copy link

I have same issue for iOS because in Uploader.swift file return body empty sting.

let result: [String : Any] = ["status": response.statusCode, "headers": response.allHeaderFields, "body": ""]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants