As a quick response:

uuid1() <http://docs.python.org/2/library/uuid.html#uuid.uuid1> may 
compromise privacy since it creates a UUID containing the computer’s 
network address. 
uuid4() <http://docs.python.org/2/library/uuid.html#uuid.uuid4> creates a 
random UUID.

Refer to this answer <http://stackoverflow.com/a/1785592/1880872> from 
Stackoverflow for further details.

On Sunday, August 2, 2015 at 10:04:33 PM UTC+2, Leon Prouger wrote:
>
> Thanks for answering, it should solve my problem. I wonder if it's safer 
> to use uuid1 on GAE, but the collision chance of uuid4 seems small enough 
> for my case.
>
> Also I added content type as you advised 
>
>
>
> On Sunday, July 26, 2015 at 7:43:50 PM UTC+3, Alex Martelli wrote:
>>
>> To generate a unique filename, I recommend the technique suggested at 
>> http://stackoverflow.com/questions/22156030/google-cloud-storage-create-file-name-automatically
>>  
>> .
>>
>> However, on an unrelated note, take care: your code seems to be missing 
>> the content_type named parameter to the open call, and you'll probably want 
>> to add it, as you did in the previous version in the create call.
>>
>> Alex
>>
>> On Sat, Jul 25, 2015 at 5:44 AM, Leon Prouger <[email protected]> wrote:
>>
>>> Hey folks, I'm learning the new Cloud Storage and question how to I 
>>> migrate my app with a least friction.
>>>
>>> Now I'm using this sample piece of code to save images:
>>>
>>> from google.appengine.api import images, files
>>>
>>>
>>> def upload(ext, stream):
>>>
>>>     file_name = files.blobstore.create(mime_type=mimetypes.types_map
>>> [ext])
>>>
>>>
>>>     with files.open(file_name, 'a') as f:
>>>
>>>         f.write(stream.getvalue())
>>>
>>>
>>>     files.finalize(file_name)
>>>
>>>     return 
>>> images.get_serving_url(files.blobstore.get_blob_key(file_name))
>>>
>>>
>>> Which I'm thinking to change to the next:
>>>
>>>
>>> def upload(ext, stream):
>>>
>>>     filename = "/images/my_file"
>>>
>>>     with gcs.open(filename, 'w') as f:
>>>
>>>         f.write(stream.getvalue())
>>>
>>>
>>>     # Blobstore API requires extra /gs to distinguish against blobstore 
>>> files.
>>>
>>>     blobstore_filename = '/gs' + filename
>>>
>>>     # This blob_key works with blobstore APIs that do not expect a
>>>
>>>     # corresponding BlobInfo in datastore.
>>>
>>>     blob_key = blobstore.create_gs_key(blobstore_filename)
>>>
>>>     return images.get_serving_url(blob_key)
>>>
>>>
>>> Which seems to work.
>>>
>>> The problem that in the old version I don't have to worry about 
>>> filenames, Files API job was to assign me one. Now I need to give a name 
>>> myself. Any way the new api should do it for me? Or maybe I should just 
>>> hash the file. 
>>>
>>>
>>> -- 
>>> 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 http://groups.google.com/group/google-appengine.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/google-appengine/145ce87c-e299-4d7f-8c8c-83f2959b5548%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/google-appengine/145ce87c-e299-4d7f-8c8c-83f2959b5548%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>

-- 
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 http://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/1c7de523-d9d0-4682-a37e-7312621ed8f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to