-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
3Questions
-
2Replies
Using Apex and VF to explore folders and files from google drive
Hi every body,
I'm trying to do an apex class and VF page to explore folders and files from google drive. I need help, I make this code the only think I have it'just and redirection page to google drive.
When I click on "Drives folder" It's show the google drive page. But what I want is to show a window like this
In fact a window like where we can a files or folders,
thanks in advanace
I'm trying to do an apex class and VF page to explore folders and files from google drive. I need help, I make this code the only think I have it'just and redirection page to google drive.
public class MyClass { private String code; public boolean val { get; set; } public blob file { get; set; } public String filetype { get; set; } public String filename { get; set; } public Id ContactId=ApexPages.currentPage().getParameters().get('Id'); public sharingClass() { } public PageReference explor() { //refreshtoken ='GDriveAPI/drive/v3/files/'; //Getting access token from google HttpRequest req = new HttpRequest(); req.setMethod('POST'); req.setEndpoint('https://www.googleapis.com/oauth2/v4/token'); req.setHeader('content-type', 'application/x-www-form-urlencoded'); req.setTimeout(60 * 1000); Http h = new Http(); String resp; HttpResponse res = h.send(req); resp = res.getBody(); System.debug(ContactId); String boundary = '----------9889464542212'; String delimiter = '\r\n--' + boundary + '\r\n'; String close_delim = '\r\n--' + boundary + '--'; //PageReference returnPage = new PageReference('/lightning/r/Contact/'+ContactId+'/view?0.source=alohaHeader'); PageReference returnPage = new PageReference('https://drive.google.com/drive/'); return returnPage; } public static void basicAuthCallout(){ HttpRequest req = new HttpRequest(); req.setEndpoint('callout:GDriveAPI/drive/v3/files/'); req.setMethod('GET'); // Specify the required user name and password to access the endpoint // As well as the header and header information String username = ''; String password = ''; Blob headerValue = Blob.valueOf(username + ':' + password); String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue); req.setHeader('Authorization', authorizationHeader); // Create a new http object to send the request object // A response object is generated as a result of the request Http http = new Http(); HTTPResponse res = http.send(req); System.debug(res.getBody()); } }My Visualforce page, see bellow
<apex:page controller="MyClass" showQuickActionVfHeader="true"> <apex:slds /> <apex:form style="margin-top:5%;margin-left:5%;width:60%"> <apex:pageblock > <br/> <br/> <br/> <br/> <apex:inputfile value="{!file}" contentType="{!filetype}" filename="{!filename}" /> <br/> <br/> <br/> <br/> <apex:commandButton styleClass="myClass" onclick="this.value = 'Drives Folders'" value="Drives Folders" action="{!explor}" /> <br/> <br/> <apex:messages styleClass="error" /> <br/> </apex:pageblock> <apex:pageblock > <!--Folder="{!basicAuthCallout}"--> </apex:pageblock> </apex:form> </apex:page>The result is
When I click on "Drives folder" It's show the google drive page. But what I want is to show a window like this
In fact a window like where we can a files or folders,
thanks in advanace
- Khalfe
- July 28, 2020
- Like
- 0
- Continue reading or reply
error code Line: 1, Column: 16 Unexpected token '('
I have this error when I try to execute this code Line: 1, Column: 16 Unexpected token '('.
I checked all the parentheses all of the in the code is correct.
I checked all the parentheses all of the in the code is correct.
public class MyId { public static void show(){ String url='https://drive.google.com/...../'; system.debug(getId(url)); } public static String getId(String gdriveUrl){ String Id = gdriveUrl.remove('https://drive.google.com/.....'); return Id; } }
- Khalfe
- July 26, 2020
- Like
- 0
- Continue reading or reply
Manage Files in folder and subfolder, like copy your files in your subolder choice
I need help, I'm trying to create a folder explorer in apex class and visualforce, it's when I want to copy a file in the folder, I can chose the folder or the sub-folder where I want to put my file in salesforce.
I tri this code bellow, but I have an error
Thanks in advance.
I tri this code bellow, but I have an error
enter public class selectFolder { public List<Account> md{get;set;} public selectFolder(ApexPages.StandardController Account) { md = new List<Account>(); md = [Select Id,Name,(Select Id,name,(Select id, name from ContentFolderMember) From Folder__c)From ContentFolderMember]; List<Document> documents = [SELECT Id, FolderId, Folder.Name FROM Document WHERE Folder.Name like 'ourLogo%' LIMIT 1]; } }The error I have is this
Select Id,Name,(Select Id,name,(Select id ^ ERROR at Row:1:Column:11 No such column 'Name' on entity 'ContentFolderMember'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.I did some research and I fine some topic talk about ContentDocuments, ContentFolder or ContentDocumentLinks, but I have no idea how it's work.
Thanks in advance.
- Khalfe
- July 25, 2020
- Like
- 0
- Continue reading or reply
error code Line: 1, Column: 16 Unexpected token '('
I have this error when I try to execute this code Line: 1, Column: 16 Unexpected token '('.
I checked all the parentheses all of the in the code is correct.
I checked all the parentheses all of the in the code is correct.
public class MyId { public static void show(){ String url='https://drive.google.com/...../'; system.debug(getId(url)); } public static String getId(String gdriveUrl){ String Id = gdriveUrl.remove('https://drive.google.com/.....'); return Id; } }
- Khalfe
- July 26, 2020
- Like
- 0
- Continue reading or reply