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

Empty MMS files posted #37

Open
madida opened this issue May 12, 2016 · 2 comments
Open

Empty MMS files posted #37

madida opened this issue May 12, 2016 · 2 comments

Comments

@madida
Copy link

madida commented May 12, 2016

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.

@no-knowledge
Copy link

Same experience with Sony Xperia Z3 Compact and Z5 compact, Android 7.1

@fictus
Copy link

fictus commented Feb 16, 2021

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

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

3 participants