I have website with java server-side.
When user submit a form, I want the application to take the text from the inputs in the form, and upload it as a .txt file to my google drive account.
What I can do so far:
I'm able to take the text from the client to the server-side.
I'm able to create a file from text.
I'm able to get an access_token using refresh token.
What I can NOT do:
I'm not able to take the file and upload it to my google drive using the valid access_token because I don't know how to do the post request.
What I have tried with no luck:
File file = new File ("omer.txt");
CloseableHttpClient client = HttpClients.createDefault();
HttpPost httpPost = new HttpPost("https://www.googleapis.com/upload/drive/v3/files?uploadType=media");
//add reuqest header
con.setRequestMethod("POST");
httpPost.setHeader("Content-Type", "text/plain");
httpPost.setHeader("Authorization", "Bearer " + access_token);
//execute the post request and upload the file to my google drive using the access token
//execute the post request and upload the file to my google drive using the access token
Here I tried to upload a txt file, I tried it but did not know what to put in the post parameters.
So : How can I upload my txt file to my google drive using my valid access_token?