storage key not a valid base64 encoding - azure storage - android - android

I am trying to upload a text blob to azure storage blob using the following code:
public static final String storageConnectionString = "DefaultEndpointsProtocol=http;"
+ "AccountName=MY_STORAGE_ACNT;"
+ "AccountKey=[MYKEY]";
CloudStorageAccount account = CloudStorageAccount.parse(storageConnectionString);
CloudBlobClient blobClient = account.createCloudBlobClient();
CloudBlobContainer container = blobClient.getContainerReference("ubiety");
container.createIfNotExists();
BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);
container.uploadPermissions(containerPermissions);
CloudBlockBlob blob1 = container.getBlockBlobReference("storage_name");
blob1.uploadText("Hello, World1");
This is a mere copy paste of the sample at BlobBasics Sample, still
I get the error
StorageKey is not a valid Base64 Encoded string.
Can someone please help. I am very sure, i am using the correct key provided at the azure portal
Thank you.

I got this message as well and it turned out I was using the wrong key. I was using the shared access signature obtained from the azure storage explorer. That's wrong. You need to grab the key from the azure portal. Go to the dashboard.
Select your storage account. You can then select "Access keys". Just pick the top key.
Then run code like this ( Scala, but Python is possible too )
var storage_account_name:String = = "storageaccountname"
// This is key1 from access keys in my user interface
var storage_account_access_key: String = "UU8udCiTs/3CEmjH3xVVFtSR7EAWZifGlSf3QoNNUDYL2GjxQ4mQ3GhuoZvO8G/eO9Z+SgY1uXrVBGHBc5u7tA=="
spark.conf.set(
"fs.azure.account.key."+storage_account_name+".blob.core.windows.net",
storage_account_access_key)
spark.read.format("csv").load("wasbs://blobname#storageaccountname.blob.core.windows.net/csvfile.csv")
In the example storageaccountname is the name of my storage account. blobname is the name of the blob in the storage account.
Good luck

Looking at the sample link you've given it looks like you're using the Java Storage library rather than the Android Storage library. If you use the Android storage library and it's associated samples that should work correctly.

Azure Account Keys with forward slash (/) does not work. See https://github.com/Azure/azure-xplat-cli/issues/3135
What I did -
com.microsoft.azure.storage.StorageCredentialsAccountAndKey creds =
new StorageCredentialsAccountAndKey(accountName, key_with_slash);
com.microsoft.azure.storage.CloudStorageAccount account = new CloudStorageAccount(creds, false);

on linux you can use the base64 program and it worked for me. Do not include the % at the end
echo -n '<ONE OF YOUR ACCESS KEY FROM BLOB STORAGE ACCOUNT>' | base64 -w 0

Related

Google Drive API List files filter file is owner = true not work

I make Android app and using Google Drive API, I want to get list files that has "ownedByMe = true". But it does not work ? That is my code:
var request = drive.files().list()
.setSpaces("drive")
.setFields("nextPageToken,files(id,name,mimeType,modifiedTime,createdTime,fileExtension,size,parents,kind" +
",webContentLink,thumbnailLink,contentHints(thumbnail),trashed,ownedByMe)")
.setPageSize(100)
.setQ("ownedByMe='true'")
.setPageToken(afterCur)
.execute()
.setQ("ownedByMe='true'")
Is not an option for searching with file.list it is in fact very limited.
You should try using
'me' in owners

Read APK file from URL in Python 2.7

I am working on a Python Script which reads the APK file which is stored in a folder on the same server on which the Script is running.
here is the code I am using:
apk_path = "/var/fibo-dev/public/uploads/apks/TvBox-release-signed-latest.apk"
apkf = APK(apk_path)
is_valid = apkf.is_valid_APK()
package = apkf.get_package()
version = apkf.androidversion
version = version['Name']
APK Parsing Package:
https://github.com/androguard/androguard
The Script reads the content of the APK like it's version, package name etc and then store the info in a csv.
As you can see the APK I am reading is stored on the same server on which the script is placed.
But now the thing is I want to read the APK which is placed on a different server. i.e. https://fibo.network/uploads/apks/18243602447plus_v4.3.4.apk
and when I try to do the same thing for the given url it doesn't work.
for example:
url = urllib2.urlopen("https://fibo.network/uploads/apks/18243602447plus_v4.3.4.apk")
apkf = APK(url.read())
It gives the error:
file() argument 1 must be encoded string without null bytes, not str
I tried to use a different methods like:
urlopen
,
requests.get
and more
But none of those worked for me.
So I am requesting you to help me to get this thing worked out.
Thanks.

Get Pretrained Inception v3 model from Open Images dataset working on Android

I tried a while to get the pretrained model working on android. The problem is, I only got the ckpt and meta file for the pretrained net. In my opinion I need the .pb for the android app. So I tried to convert the given files to an .pb file.
Therefore I tried the freeze_graph.py but without succes. So I used the example code from https://github.com/openimages/dataset/blob/master/tools/classify.py and modified it to store a pb. file after loading
if not os.path.exists(FLAGS.checkpoint):
tf.logging.fatal(
'Checkpoint %s does not exist. Have you download it? See tools/download_data.sh',
FLAGS.checkpoint)
g = tf.Graph()
with g.as_default():
input_image = tf.placeholder(tf.string)
processed_image = PreprocessImage(input_image)
with slim.arg_scope(inception.inception_v3_arg_scope()):
logits, end_points = inception.inception_v3(
processed_image, num_classes=FLAGS.num_classes, is_training=False)
predictions = end_points['multi_predictions'] = tf.nn.sigmoid(
logits, name='multi_predictions')
init_op = control_flow_ops.group(tf.global_variables_initializer(),
tf.global_variables_initializer(),
data_flow_ops.initialize_all_tables())
saver = tf_saver.Saver()
sess = tf.Session()
saver.restore(sess, FLAGS.checkpoint)
outpt_filename = 'output_graph.pb'
#output_graph_def = sess.graph.as_graph_def()
output_graph_def = graph_util.convert_variables_to_constants(sess, sess.graph.as_graph_def(), ["multi_predictions"])
with gfile.FastGFile(outpt_filename, 'wb') as f:
f.write(output_graph_def.SerializeToString())
Now my problem is that I have the .pb file but I don't have any opinion what is the input node name and I am not sure if multi_predictions is the right output name. In the example android app I have to specify both. And the android app crashed with:
tensorflow_inference_jni.cc:138 Could not create Tensorflow Graph: Invalid argument: No OpKernel was registered to support Op 'DecodeJpeg' with these attrs.
I don't know if there are more problem by trying to fix the .pb problem. Or if anyone knows a better way to port the ckpt and meta files to a .pd file in my case or knows a source for the final file with input and ouput names please give me a hint to complete this task.
Thanks
You'll need to use the optimize_for_inference.py script to strip out the unused nodes in your graph. "decodeJpeg" is not supported on Android -- pixel values should be fed in directly. ClassifierActivity.java has more detail about the specific nodes to use for inception v3.

Why can't we use file name to query excel file on Google Drive?

I have an app where I want to query excel on Google Drive as and when a new excel with 'a fixed file name format' is added to the drive. Why does Google not allow us to query the file by filename instead of file id?
For example my app queries a file names August2016.xls and next month it should automatically look for a new file with file name September2016.xls. Currently this is not possible because the application should have the file id. Am I missing something? Is it possible too query a Google Drive file by file name?
The "getFilesByName" function of the "Folder" class should work:
var theXLSFile = null;
// the id of the folder that has the excel files.
var FOLDER_ID = "xxxxxxxxx";
// alternatively, could use "getFoldersByName".
var folder = DriveApp.getFolderById(folderId);
var FILE_NAME = "September2016.xls";
var files = folder.getFilesByName(FILE_NAME);
if (files.length > 0)
theXLSFile = files[0];
Reference:
https://developers.google.com/apps-script/reference/drive/folder#getFilesByName(String)
Thanks #opowell your answer helped me find the correct Google API. I am doing android development and here are the links to get started on Google Drive API & getFile function.
1) https://developers.google.com/drive/android/get-started
2) Querying for Files using com.google.android.gms.drive.query package - https://developers.google.com/drive/android/queries
3) Google sample- https://github.com/googledrive/android-demos/

google cloud storage issue

I am using google cloud storage to store images on android..I created project in google developers console and gave all id's from that project.
private static final String PROJECT_ID_PROPERTY = "xxxxxxxxxxxxxx"; //project ID
private static final String APPLICATION_NAME_PROPERTY = "refined"; //application name, can be any
private static final String ACCOUNT_ID_PROPERTY = "xxxxxxxxxxxxxxx-n5kqcd842faki0se7s82vpcf9l1rbvui#developer.gserviceaccount.com"; //user account email
Downloaded P12 file and accessing from the code for setting p12 key.
When I tried on 2 days back , images got uploaded correctly and I could see them in the browser..But when I try today the same code, it is giving forbidded issue.
{"code":403,"errors": [{"domain":"global","message":"Forbidden","reason":"forbidden"}],"message":"Forbidden"}
What could be the reason?
I could solve the issue...Issue was with permissions...
I gave write permissions on the bucket for the client ID, then it is working now.
Thanks for all

Categories

Resources