Azure Sotarage on Android - open failed: ENOENT (No such file or directory)

Asked

Viewed 164 times

0

I’m having a problem with the AZURE STORAGE API for Android which is when I try to upload an image with the following code

storageAccount = CloudStorageAccount.parse(storageConnectionString);
            CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
            // Retrieve reference to a previously created container.
            CloudBlobContainer container = blobClient.getContainerReference("images");
            // Create the container if it does not exist
            container.createIfNotExists();
            // Create a permissions object
            BlobContainerPermissions containerPermissions = new BlobContainerPermissions();

            // Include public access in the permissions object
            containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);

            // Set the permissions on the container
            container.uploadPermissions(containerPermissions);
            System.out.println("--- " + pathFile);

            // Create or overwrite the "myimage.jpg" blob with contents from a local file
            CloudBlockBlob blob = container.getBlockBlobReference(pathFile.toString());

            File source = new File(currImageURI.toString());
            blob.upload(new FileInputStream(source.getAbsolutePath()), source.length());

When System.out.println the result is "/Storage/Emulated/0/Pictures/1489083183528.jpg" however I get the error right away

java.io.Filenotfoundexception: /content:/media/External/images/media/602: open failed: ENOENT (No such file or directory)

Has anyone had this problem or knows why this path appears instead of the other?

  • The problem does not seem to be in the API, but rather in the file path. When you do getBlockBlobReference() you pass a path where he complains that the file is not there.

  • The problem lies there is that the image is there and with that way...

  • I will fetch the URI via public String getRealPathFromURI(Uri Uri) { Cursor cursor = getContentResolver(). query(Uri, null, null, null, null); cursor.moveToFirst(); int idx = cursor.getColumnIndex(Mediastore.Images.Imagecolumns.DATA); Return cursor.getString(idx); }

1 answer

0


I solved my question the problem is that I was barely passing the path in this code line Cloudblockblob blob = container.getBlockBlobReference(pathFile.toString());

Browser other questions tagged

You are not signed in. Login or sign up in order to post.