Hi Adam, 

Maybe I'm confusing the options of store data on the Google Infrastructure. 
I want store the profile photos to my users in my GAE app, and finding way 
to do this I found Google Cloud Storage, using the library cloudstorage for 
python but also saw blobstore and gcloud and I'm a bit confusing.
When I loaded a photo with gcs.open I can see this in the dev server in the 
section BlobStore Viewer, because of this I thought that blobstore and GCS 
is more or less the same thing.

When, when I make this:

gcs_file = gcs.open(filename, 'w', ...)        
gcs_file.write(datos)        
gcs_file.close()

After I can see in Blobstore Viewer in dev_server web console a new file, 
and If I use this code:
        
        blobstore_filename = '/gs' + filename
        key = blobstore.create_gs_key(blobstore_filename)
        return get_serving_url(key)

I can get the url where the image is stored to use to show it wherever i 
want.

For this reason, I thought that was easy way to obtain from url that I have 
the way to erase que photo or the file that this url refers.

Thanks you very much for all your help Adam.

El domingo, 17 de abril de 2016, 0:56:34 (UTC+2), Adam (Cloud Platform 
Support) escribió:
>
> First off, Google Cloud Storage is not Blobstore. You can create a key for 
> use with Blobstore with blobstore.create_gs_key(), but you should only do 
> this if you really need to use Blobstore API for something (eg. with the 
> Images API). You should not treat Blobstore and GCS as the same thing or 
> intermingle them needlessly.
>
> So adding to that, GCS doesn't understand or care about blob keys 
> <https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/functions>,
>  
> so gcs.delete(key) won't work. Objects that are uploaded to Blobstore don't 
> necessarily exist in GCS, so there isn't a way to get a GCS file name from 
> a blob key*. You need to use the GCS file path directly, eg. 
> gcs.delete('/mybucket/path/to/myobject').
>
> So to avoid this type of problem you should always use 'cloudstorage' and 
> deal with objects in terms of GCS files, using blobstore.create_gs_key() 
> only when you need to use some function that needs the Blobstore API. You 
> can make Blobstore talk to GCS, but not the other way around.
>
> ** The filename you get from BlobInfo 
> <https://cloud.google.com/appengine/docs/python/refdocs/google.appengine.ext.blobstore.blobstore#google.appengine.ext.blobstore.blobstore.BlobInfo>
>  
> is the filename from the user's machine when they uploaded the blob, not 
> the filename in GCS.*
>
> On Saturday, April 16, 2016 at 5:22:07 PM UTC-4, Juan Antonio Fernández 
> Sánchez wrote:
>>
>> I'm saving images in cloudstore (blobstore) using 'cloudstorage' library 
>> in python. 
>>
>> Well, this images are the image profile from  users and I get the url 
>> from blobstore to save this with the rest of data of user.
>> And now I' m trying develop the way to erase this files using the same 
>> url that I have saved in the data block of users, but I dont find a simple 
>> way to do this with the 'cloudstorage' library.
>>
>> I could save the filename of the photos of users in DB togheter to url to 
>> access faster, but I prefer know how I can could make this.
>>
>> Thanks you so much for help.
>>
>> Code example that I want more o less:
>>
>> def DeleteFile(self, url):
>> key = keyFromUrl(url)
>> gcs.delete(key)
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/561d6c7b-cdb6-4730-a586-58814fa9114b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • [google-appengine] H... Juan Antonio Fernández Sánchez
    • [google-appengi... 'Adam (Cloud Platform Support)' via Google App Engine
      • [google-app... Juan Antonio Fernández Sánchez
        • [google... 'Adam (Cloud Platform Support)' via Google App Engine
          • [go... Juan Antonio Fernández Sánchez
            • ... 'Adam (Cloud Platform Support)' via Google App Engine

Reply via email to