0

When trying to get base64 encoded data from IOS through API and decoding it in server giving empty response for large files. Means its working fine for audio files less than 5MB only. I can't even identify this problem is happening while encoding in app side or while decoding in server side.

So how can I fix this problem?

Please help me to solve this. All your answers will be appreciated. Thank you.

Shihas
  • 814
  • 15
  • 44
  • How does the server receive the data from the app? It might be a size limit. – KIKO Software Sep 26 '17 at 09:11
  • In server side its getting like a POST value. And also server configuration the limit has been changed to 30MB. – Shihas Sep 26 '17 at 09:12
  • @KIKOSoftware Will there be any problem on encoding large sized files? – Shihas Sep 26 '17 at 09:14
  • Well, I think you need to test things better. For instance: 1. If you encode and decode, without sending, does it work? 2. Does all the data you send arrive? Better still, make sure you always receive all data by adding a size parameter or hash. – KIKO Software Sep 26 '17 at 09:16
  • The file less than 5MB are uploading properly. That means problem will be on encoding large sized file. Right? – Shihas Sep 26 '17 at 09:20
  • Yes, obviously you need to test the larger files, that's where you have a problem. There will be a limit on the size of data you encode and decode with Base64, but 5 MB is not that much. My guess is that it is the transport of the data that is the limiting factor. I cannot help you much further because you have not posted even one line of code. – KIKO Software Sep 26 '17 at 09:22
  • Have you seen this SO thread? https://stackoverflow.com/questions/7920780/is-it-possible-to-base64-encode-a-file-in-chunks – Shahroze Nawaz Sep 26 '17 at 09:26
  • Yeah I know. I'm handling the server side only. Means just decoding the coming data and saving in folder (`file_put_contents($path, base64_decode($url[0]));`) like this. I posted this question to understand that the problem will be from server side or the app side. – Shihas Sep 26 '17 at 09:27
  • Also, have you checked the max upload size and max execution time? I faced this when converting images to base64 and uploading to magento store. – Shahroze Nawaz Sep 26 '17 at 09:49
  • @ShahrozeNawaz Yes. I keep max_upload_size 30MB and max_execution_time 20 minutes too. – Shihas Sep 26 '17 at 09:56

1 Answers1

2
file_put_contents('audio.mp3', base64_decode($data));
Rohan Varma
  • 101
  • 7