-
- String mimeType = getContentResolver().getType(uri);
-
- if (mimeType.contains("image")) {
- String[] CONTENT_PROJECTION = { Images.Media.DATA,
- Images.Media.DISPLAY_NAME, Images.Media.MIME_TYPE,
- Images.Media.SIZE };
- Cursor c = getContentResolver().query(uri, CONTENT_PROJECTION, null,
- null, null);
- c.moveToFirst();
- int index = c.getColumnIndex(Images.Media.DATA);
- String data = c.getString(index);
- String filePath = mUploadPath +
- c.getString(c.getColumnIndex(Images.Media.DISPLAY_NAME));
- String fullTempPath = FileStorageUtils.getTemporalPath(getAccount().name)
- + filePath;
- InputStream inputStream = null;
- FileOutputStream outputStream = null;
- if (data == null) {
- try {
- inputStream = getContentResolver().openInputStream(uri);
- File cacheFile = new File(fullTempPath);
- cacheFile.createNewFile();
- outputStream = new FileOutputStream(fullTempPath);
- byte[] buffer = new byte[4096];
-
- int count = 0;
-
- while ((count = inputStream.read(buffer)) > 0) {
- outputStream.write(buffer, 0, count);
- }
-
- outputStream.close();
- inputStream.close();
-
- data = fullTempPath;
- }catch (Exception e) {
- if (inputStream != null) {
- try {
- inputStream.close();
- } catch (Exception e1) {
-
- }
- }
-
- if (outputStream != null) {
- try {
- outputStream.close();
- } catch (Exception e1) {
-
- }
- }
-
- if (fullTempPath != null) {
- File f = new File(fullTempPath);
- f.delete();
- }
- }
- }
-
- local.add(data);
- remote.add(mUploadPath +
- c.getString(c.getColumnIndex(Images.Media.DISPLAY_NAME)));
-
- }
- else if (mimeType.contains("video")) {
- String[] CONTENT_PROJECTION = { Video.Media.DATA,
+ String mimeType = getContentResolver().getType(uri);
+
+ if (mimeType.contains("image")) {
+ String[] CONTENT_PROJECTION = { Images.Media.DATA,
+ Images.Media.DISPLAY_NAME, Images.Media.MIME_TYPE,
+ Images.Media.SIZE };
+ Cursor c = getContentResolver().query(uri, CONTENT_PROJECTION, null,
+ null, null);
+ c.moveToFirst();
+ int index = c.getColumnIndex(Images.Media.DATA);
+ data = c.getString(index);
+ filePath = mUploadPath +
+ c.getString(c.getColumnIndex(Images.Media.DISPLAY_NAME));
+
+ } else if (mimeType.contains("video")) {
+ String[] CONTENT_PROJECTION = { Video.Media.DATA,