EnvayaSMS
EnvayaSMS copied to clipboard
Empty MMS files posted
We've been trying to use Envaya to post MMS files onto a server but all image file sizes are zero. SMIL files appear ok. Below is a print out of the $_FILES array we're receiving from the App.
Android 5.1 HTC Desire 626
` ( [part0] => Array ( [name] => smil.xml [type] => application/smil [tmp_name] => /tmp/phph7vfqn [error] => 0 [size] => 259 )
[part1] => Array
(
[name] => image000000.jpg
[type] => image/jpeg
[tmp_name] => /tmp/phpq3EhVv
[error] => 0
[size] => 0
)
) `
Would really appreciate any help.
Same experience with Sony Xperia Z3 Compact and Z5 compact, Android 7.1
I was having the same issue. after a few days of messing with the code I noticed this method was returning empty bytes[]
` public byte[] getData() throws IOException { int length = (int)getDataLength(); byte[] bytes = new byte[length];
int offset = 0;
int bytesRead = 0;
InputStream in = openInputStream();
while (offset < bytes.length)
{
bytesRead = in.read(bytes, offset, bytes.length - offset);
if (bytesRead < 0)
{
break;
}
offset += bytesRead;
}
in.close();
if (offset < bytes.length)
{
throw new IOException("Failed to read complete data of MMS part");
}
return bytes;
}
`
I updated the method to this and now it works:
` public byte[] getData() throws IOException { InputStream inputStream = openInputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); int nRead; byte[] data = new byte[RAW_DATA_BLOCK_SIZE];
while ((nRead = inputStream.read(data, 0, data.length)) != -1) {
buffer.write(data, 0, nRead);
}
buffer.flush();
return buffer.toByteArray();
}
`
I have attached a modified version of the .apk containing this change; 2021-EnvayaSMS-release_imgs_in.zip