ath0mas commented on code in PR #277:
URL: 
https://github.com/apache/cordova-plugin-media-capture/pull/277#discussion_r1304946594


##########
src/android/Capture.java:
##########
@@ -377,19 +381,60 @@ else if (resultCode == Activity.RESULT_CANCELED) {
         }
     }
 
-
     public void onAudioActivityResult(Request req, Intent intent) {
-        // Get the uri of the audio clip
-        Uri data = intent.getData();
-        if (data == null) {
+        Uri srcContentUri = intent.getData();
+
+        if (srcContentUri == null) {
             pendingRequests.resolveWithFailure(req, 
createErrorObject(CAPTURE_NO_MEDIA_FILES, "Error: data is null"));
             return;
         }
 
-        // Create a file object from the uri
-        JSONObject mediaFile = createMediaFile(data);
-        if (mediaFile == null) {
-            pendingRequests.resolveWithFailure(req, 
createErrorObject(CAPTURE_INTERNAL_ERR, "Error: no mediaFile created from " + 
data));
+        // Get file name
+        String srcContentUriString = srcContentUri.toString();
+        String fileName = 
srcContentUriString.substring(srcContentUriString.lastIndexOf('/') + 1);
+
+        // Create dest file path
+        String tempRoot = 
cordova.getActivity().getCacheDir().getAbsolutePath();
+        String destFile = tempRoot + "/" + fileName;
+
+        // Create dest file
+        File tmpRootFile = new File(destFile);
+
+        try {
+            // If file exists
+            if (tmpRootFile.createNewFile()) {
+                FileOutputStream destFOS = new FileOutputStream(tmpRootFile);

Review Comment:
   `destFOS` and `srcIS` should be declared in a try-with-resources statement 
each



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to