Fix upload mms again
This commit is contained in:
		@ -28,6 +28,8 @@ public class UploadFile extends Transfer {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public Uri uri;
 | 
					    public Uri uri;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public UploadFile() {
 | 
					    public UploadFile() {
 | 
				
			||||||
        this.id = View.generateViewId();
 | 
					        this.id = View.generateViewId();
 | 
				
			||||||
        instances.add(this);
 | 
					        instances.add(this);
 | 
				
			||||||
@ -44,9 +46,19 @@ public class UploadFile extends Transfer {
 | 
				
			|||||||
            Cursor cursor = activity.getContentResolver().query(uri, null, null, null, null);
 | 
					            Cursor cursor = activity.getContentResolver().query(uri, null, null, null, null);
 | 
				
			||||||
            cursor.moveToFirst();
 | 
					            cursor.moveToFirst();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            file.name = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
 | 
					            file.type = activity.getContentResolver().getType(uri);
 | 
				
			||||||
            file.size = cursor.getLong(cursor.getColumnIndex(OpenableColumns.SIZE));
 | 
					
 | 
				
			||||||
 | 
					            int col_name = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
 | 
				
			||||||
 | 
					            if (col_name != -1)
 | 
				
			||||||
 | 
					                file.name = cursor.getString(col_name);
 | 
				
			||||||
 | 
					            if(file.name == null)
 | 
				
			||||||
 | 
					                file.name = file.type.split("/")[0] + "_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + "." + file.type.split("/")[1];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int col_size = cursor.getColumnIndex(OpenableColumns.SIZE);
 | 
				
			||||||
 | 
					            if (col_name != -1) {
 | 
				
			||||||
 | 
					                file.size = cursor.getLong(col_size);
 | 
				
			||||||
                file.sizeSI = Transfer.humanReadableByteCountBin(file.size);
 | 
					                file.sizeSI = Transfer.humanReadableByteCountBin(file.size);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            file.AddTransfer();
 | 
					            file.AddTransfer();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -116,15 +128,7 @@ public class UploadFile extends Transfer {
 | 
				
			|||||||
        Cursor cursor = activity.getContentResolver().query(uri, null, null, null, null);
 | 
					        Cursor cursor = activity.getContentResolver().query(uri, null, null, null, null);
 | 
				
			||||||
        cursor.moveToFirst();
 | 
					        cursor.moveToFirst();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        String type = activity.getContentResolver().getType(uri);
 | 
					        String fileNameUTF8 = new String(name.getBytes(), StandardCharsets.ISO_8859_1);
 | 
				
			||||||
 | 
					 | 
				
			||||||
        String fileName = null;
 | 
					 | 
				
			||||||
        int col_name = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
 | 
					 | 
				
			||||||
        if (col_name != -1)
 | 
					 | 
				
			||||||
            fileName = cursor.getString(col_name);
 | 
					 | 
				
			||||||
        if(fileName == null)
 | 
					 | 
				
			||||||
            fileName = type.split("/")[0] + "_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + "." + type.split("/")[1];
 | 
					 | 
				
			||||||
        String fileNameUTF8 = new String(fileName.getBytes(), StandardCharsets.ISO_8859_1);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        url = new URL(protocol, host, port, root + "/upload.php");
 | 
					        url = new URL(protocol, host, port, root + "/upload.php");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -152,6 +156,7 @@ public class UploadFile extends Transfer {
 | 
				
			|||||||
        InputStream in = activity.getContentResolver().openInputStream(uri);
 | 
					        InputStream in = activity.getContentResolver().openInputStream(uri);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        size = in.available();
 | 
					        size = in.available();
 | 
				
			||||||
 | 
					        sizeSI = Transfer.humanReadableByteCountBin(size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        while ((bufferLength = in.read(buffer)) > 0) {
 | 
					        while ((bufferLength = in.read(buffer)) > 0) {
 | 
				
			||||||
            request.write(buffer, 0, bufferLength);
 | 
					            request.write(buffer, 0, bufferLength);
 | 
				
			||||||
@ -168,7 +173,7 @@ public class UploadFile extends Transfer {
 | 
				
			|||||||
        int responseCode = conn.getResponseCode();
 | 
					        int responseCode = conn.getResponseCode();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (responseCode == HttpURLConnection.HTTP_OK) {
 | 
					        if (responseCode == HttpURLConnection.HTTP_OK) {
 | 
				
			||||||
            message = "File " + fileName + " successful upload";
 | 
					            message = "File " + name + " successful upload";
 | 
				
			||||||
            state = Transfer.STATE_SUCCESS;
 | 
					            state = Transfer.STATE_SUCCESS;
 | 
				
			||||||
            progressEnd();
 | 
					            progressEnd();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user