Esempio n. 1
0
 def delete_photo(itemID):
     """
     This method deletes a photo from the Google Cloud Storage
     """
     filename = str(itemID) + ".jpg"
     gcs_api = GoogleCloudStorageAPI()
     return gcs_api.json_delete(filename)
Esempio n. 2
0
    def save_photo(itemID, photo_url):
        """
        This method uploads photo to the Google Cloud Storage, and returns the URL
        """
        photo = urllib.urlopen(photo_url).read()
        if not photo:
            return None
        filename = str(itemID) + ".jpg"

        gcs_api = GoogleCloudStorageAPI()
        gcs_api.json_upload(filename=filename,
                            content=photo,
                            content_type="image/jpeg")
        result_url = "http://storage.googleapis.com/" + \
                     settings.GCS_BUCKET + \
                     "/" + filename
        return result_url