+ Start a Discussion
Ashmi PatelAshmi Patel 

cant upload file from salforce to drive

i cant upload file from salesforce to google drive. This is my code for uploading file.

 public PageReference DriveUploadAuth()
    document.AuthorId = UserInfo.getUserId();
    document.FolderId = UserInfo.getUserId();
            insert document;
    catch(DMLException e){
    ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading file'));
      return null;
    finally {
      document.body = null; // clears the viewstate
      document = new Document();
         PageReference pg = new PageReference(GoogleDriveAuthUri (key , redirect_uri)) ;
         return pg;
         ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'File uploaded successfully'));
         return null;     

it will redirect me. bt I cant upload documents on google drive
need help