prayagverma / gdata-python-client

Automatically exported from code.google.com/p/gdata-python-client
1 stars 0 forks source link

Uploaded Files and folders are only being displayed after a very long time in Gdrive #678

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Use the following function(s) to upload a file, or create a folder in GDrive ( 
not very different from the examples provided in the Docs ):

################################################################################
##
    def upload_file(self,filename,fullpath,drive_service, body):
        """
        returns an instance of the file if successful or None
        """
        tpl = (drive_service, filename)
        print("entered upload_file() %s" % (tpl,))
        fisier = None
        for retry in range(5):
            try:
                media_body = MediaFileUpload(fullpath, mimetype=body['mimeType'], resumable=True)
                fisier = drive_service.files().insert(body=body, media_body=media_body).execute()
            except Exception as e:
                import traceback
                print("Something went wrong uploading the file, retrying: %s" % e)
                traceback.print_exc(file=sys.stdout)
                import time
                time.sleep(2)
                continue
            break
        print("exiting upload_file() %s" % fisier)
        return(fisier)

##############################################################################

The function returns a JSON object containing the file metadata: 

Uploading: ('/home/andrei/GoogleDrive/learn_js/js/dom_scripting.js', 'js')
entered upload_file() (<apiclient.discovery.Resource object at 0x26230d0>, 
'/home/andrei/GoogleDrive/learn_js/js/dom_scripting.js')
exiting upload_file() 

{u'mimeType': u'text/x-c++', u'appDataContents': False, u'labels': 
{u'restricted': False, u'starred': False, u'viewed': True, u'hidden': False, 
u'trashed': False}, u'etag': 
u'"PA40KOhMf9e-1Hypww_TkG8doNA/MTM3ODg0NDg4NTU0NA"', u'lastModifyingUserName': 
u'Andrei Sasu', u'writersCanShare': True, u'id': 
u'0B9lf74BG-VykUHFHM3FUUkU0cmc', u'lastModifyingUser': {u'kind': u'drive#user', 
u'isAuthenticatedUser': True, u'displayName': u'Andrei Sasu', u'permissionId': 
u'00166468771667652009'}, u'title': u'dom_scripting.js', u'ownerNames': 
[u'Andrei Sasu'], u'lastViewedByMeDate': u'2013-09-10T20:28:05.544Z', 
u'parents': [{u'isRoot': False, u'kind': u'drive#parentReference', u'id': 
u'0B9lf74BG-VykeVh4NURKQzFXQmc', u'selfLink': 
u'https://www.googleapis.com/drive/v2/files/0B9lf74BG-VykUHFHM3FUUkU0cmc/parents
/0B9lf74BG-VykeVh4NURKQzFXQmc', u'parentLink': 
u'https://www.googleapis.com/drive/v2/files/0B9lf74BG-VykeVh4NURKQzFXQmc'}], 
u'shared': False, u'originalFilename': u'dom_scripting.js', u'description': 
u'/home/andrei/GoogleDrive/learn_js/js/dom_scripting.js', u'webContentLink': 
u'https://docs.google.com/uc?id=0B9lf74BG-VykUHFHM3FUUkU0cmc&export=download', 
u'editable': True, u'owners': [{u'kind': u'drive#user', u'isAuthenticatedUser': 
True, u'displayName': u'Andrei Sasu', u'permissionId': 
u'00166468771667652009'}], u'quotaBytesUsed': u'1024', u'fileSize': u'1024', 
u'createdDate': u'2013-09-10T20:28:05.851Z', u'md5Checksum': 
u'c7e9c7a60ae226199778ca95cc61afc2', u'iconLink': 
u'https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png', 
u'kind': u'drive#file', u'alternateLink': 
u'https://docs.google.com/file/d/0B9lf74BG-VykUHFHM3FUUkU0cmc/edit?usp=drivesdk'
, u'copyable': True, u'modifiedByMeDate': u'2013-09-10T20:28:05.544Z', 
u'downloadUrl': 
u'https://doc-0g-48-docs.googleusercontent.com/docs/securesc/vt04si6699j170dou2m
leaphsd5f3o1q/5506qpgk6tpt06lq543jdl4uul0hbcg2/1378843200000/0016646877166765200
9/00166468771667652009/0B9lf74BG-VykUHFHM3FUUkU0cmc?h=16653014193614665626&e=dow
nload&gd=true', u'userPermission': {u'kind': u'drive#permission', u'etag': 
u'"PA40KOhMf9e-1Hypww_TkG8doNA/6ADC3LVcZTUi1j1GbIpDwkQcnkA"', u'role': 
u'owner', u'type': u'user', u'id': u'me', u'selfLink': 
u'https://www.googleapis.com/drive/v2/files/0B9lf74BG-VykUHFHM3FUUkU0cmc/permiss
ions/me'}, u'fileExtension': u'js', u'selfLink': 
u'https://www.googleapis.com/drive/v2/files/0B9lf74BG-VykUHFHM3FUUkU0cmc', 
u'modifiedDate': u'2013-09-10T20:28:05.544Z'}

However, the file is NOT being displayed in Google Drive, only after a veeery 
long time ( aprox 30min - 1hr ). 

The exact same code used to work flawlessly yesterday.

Original issue reported on code.google.com by andrei.s...@gmail.com on 10 Sep 2013 at 8:40