google cloud storage sample not working - google-cloud-storage

anyone else having an issue getting google cloud storage API sample to work?
https://developers.google.com/appengine/docs/python/googlestorage/overview#Complete_Sample_App
I followed all the directions which are very straight forward. You simply paste the code form the sample and it should work. However you do have to update your bucket names. I am updating this line
# TODO: Change to a bucket your app can write to.
READ_PATH = '/gs/bucket/obj'
to
READ_PATH = 'gs://mybucketname'
it does not work?
I updated it as such because that's how i access my bucket via gsutil
Anyone got this to work?

In the Files API, the path does not follow the gs:// URL scheme. As the example states, you need to make it:
/gs/mybucketname/myobjectname

Related

Is there a way to change the google storage signed url to not include the name of the file?

I have a method that gets a signed url for a blob in a google bucket and then returns that to users. Ideally, I could change the name of the file shown as well. Is this possible?
An example is:
https://storage.googleapis.com/<bucket>/<path to file.mp4>?Expires=1580050133&GoogleAccessId=<access-id>&Signature=<signature>
The part that I'd like to set myself is <path to file.mp4>.
The only way I can think of is having something in the middle that will be responsible for the name "swap".
For example Google App Engine with an http trigger or Cloud Function with storage trigger that whenever you need it will fetch the object, rename it, and either provide it to the user directly or store it with the new name in another bucket.
Keep in mind that things you want to store temporarily in GAE or Cloud Functions need to be stored in "/tmp" directory.
Then for renaming, if you are using GAE possibly you can use something like:
import os
os.system([YOUR_SHELL_COMMAND])
However, the easiest but more costly approach is to set a Function with storage trigger that whenever an object is uploaded it will store a copy of it with the desired new name in a different bucket that you will use for the users.

Access file content within an Azure Dev Ops/VSTS artifact using REST API

I am looking to get the contents of a file I pushed as an artifact to Azure DevOps
I was able to get a json response with a URL to the artifact zip by using this API
https://dev.azure.com/uifabric/cd9e4e13-b8db-429a-9c21-499bf1c98639/_apis/build/builds/8838/artifacts?artifactName=drop&api-version=5.0
However, what I really want is the contents of a file called bundlesizes.json within this zip.
I did come across the Get File API here which mentions an API as follows
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/artifacts?artifactName={artifactName}&fileId={fileId}&fileName={fileName}&api-version=5.0
I tried replacing it as follows
https://dev.azure.com/uifabric/fabricpublic/_apis/build/builds/8838/artifacts?artifactName=drop&fileId=bundlesizes.json&fileName=bundlesizes.json&api-version=5.0
However, I get this error
I think what I am missing is the fileId field, where I am not aware what needs to go in. The documentation says fileId is the The primary key for the file. However, I don't know where I can find it.
Microsoft doesn't have complete documentation on how to get FileID.
You can take a different approach and download the file using below API. You can get the ContainerID through GET build details.
https://collectionurl/tfs/defaultcollection/_apis/resources/Containers/${containerid}?itempath=drop

Cannot find audio file in google bucket with google speech API

With the Google Speech API (using the python sample code), you need to have your audio files on google cloud when longer than 1 minute. According to some sample code, you can use a path like
gs://python-docs-samples-tests/speech/audio.flac.
So I put my audio files in a bucket, and use (I believe) the correct path (i.e. gs://bucket-name/foldername/myaudiofile.wav), yet I get an error .
NotFound: 404 No such object: bucket-name/foldername/myaudiofile.wav
Even if I put the permission on public (which I rather not do), it cannot find the file. I have the feeling I am forgetting something very trivial here... But still haven't found it.
Go to the cloud console > select the project > go to Storage > Browse the buckets and make sure the file is actually there. Best way you can tell, IMO.

Visual studio unable to add swagger metadata file in my rest api client

I am new to mobile development. As i am familiar with c# .net so i am using xamarin plugin for visual studio. I have created a sample app in which i have used SQLite, created a DB and then performed CRUD operations. At this point all things are working good. But i already have a local DB and i want to use it. For this i have made an offline Azure api using swagger and on Release i have saved the files locally by using File System in release option in VS. Now i want to add my app as rest api client and want to use my local DB. But when i try to add as rest api client and then i select select an existing swagger file so while browsing i can't find any file. For reference please see the images bellow
So when i click browse and goto the location where i have saved my files for swagger i get nothing as shown in bellow image
Also it's finding the .json extension file which is not present in my publish api.
I don't know why it's happening, also as already told above i am new to mobile development i am not sure what to do. Kindly see the bellow image of my swagger UI
Any help would be highly appreciated
The URL you listed is for the user-friendly reference docs for your API; there should be a corresponding URL for the JSON definition endpoint for your API. Use this instead in the Add Rest API Client dialog in the "Swagger URL" option.
The other option is to use this peer URL to download the JSON description of your REST API into a local .json file and reference that when generating your client access classes.
For an example of these two endpoints, see https://msdn.microsoft.com/en-us/library/mt788315.aspx#Anchor_1.
Why you are using azure? I guess your are working in a company so they must have a server. Just publish your services on the server and then sync it with your mobile app and DB. This is the easiest and free way to do it. You can use Rest services for that

Google Cloud Storage : PUT Object vs POST Object to upload file.?

Can any one please explain me what is main difference between PUT Object vs POST Object to upload file.
What are advantages and disadvantages of using each ??
Thanks.
Use POST if you cannot set the Authorization header -- generally because you are uploading with an HTML form.
Use PUT for everything else.