I am super new to using API's. I am trying to turn the drive api on and the final step is
Click the file_download (Download JSON) button to the right of the client ID.
Move this file to your working directory and rename it client_secret.json.
I already downloaded the file (JSON) and it's on my hard drive but I can't seem to navigate to my "working directory". Where is it? and how can I get to it from my "Api and services - Dashboard"
I found the answer in the chapter 'Authentication with OAuth' of google-api-php-client.
Set the path to these credentials using Google_Client::setAuthConfig:
$client = new Google_Client();
$client->setAuthConfig('/path/to/client_credentials.json');
You can put the file whatever you want, but only set the path in the mentied place.
Related
I have just recently starting coding and using AppScrpits, and I have set up an app that among other things creates PDF files in a Drive folder and stores the view links in a Sheet.
These files should be accesible only by people with the same domain in view only, non-sharable and non-downloadable.
I set the access and permission as intenden and everything works fine, but the PDF files are still downloadable and sharable by the viewers. Normally I would set this option by right cliking the file and setting the configuration manually, but since I have to process a large number of files I wonder if there is anyway to do this with appscripts.
With the code below access and view permission works as intended, but I can't find any referance to set aditional configuration so that the file is non-downloable or sharable.
let pdf = DriveApp.getFileById(nuevo.getId())
.getBlob()
.getAs('application/pdf');
pdf.setName('placeholder'.pdf');
let file = ubicacion.createFile(pdf);
file.setSharing(DriveApp.Access.DOMAIN_WITH_LINK, DriveApp.Permission.VIEW);
var ultimaFila = sheet.getLastRow() +1;
sheet.getRange('Hoja 1!B' + ultimaFila).setValue(file.getUrl());
Thanks!!!
I can use GAS script to upload a file to my drive as below:
media = MediaFileUpload(
filename,
mimetype=mimetype,
resumable=True
)
request = service.files().create(
media_body=media,
body={'name': remotefilename, 'parents': [folderId]}
)
But if I upload the same file multiple times, it will generate multiple copies. Is it possible to keep the same file but keep different version? just like what the UI update version does?
Solution:
Instead of a create request, you can issue an update request to an existing file with newRevision parameter set to true to create a new revision for the same file.
For more information on how to use Files: update, you can check the official API documentation.
I'm new to using the data management API to gain access to BIM360Docs, I've successfully downloaded a file from any folder and I can upload to the project files folder, however the issue lies with uploading to the plans folder, all the API calls seem happy and appears to work, but when I check the actual BIM360Docs website it's not there, when I use the API call to display a folders contents it is there, so it appears to be uploading correctly yet isn't visible for some reason?
Here it is being uploaded successfully:
Here it is being visible using the get folder contents API call but not in docs:
So it is there and I can download it and everything is hunky dory I just can't see it on the website.
PS I'm using the step by step guide on the forge site (I'm unable to link as I don't have enough rep).
Can you tell me to what folder location are you uploading? I'm thinking maybe you are not posting the file to the right location, and that is why you can download it only. In that sense you are correctly creating the storage location, the problem is you are probably uploading your file to the wrong folder. Something I can suggest is the following, get a list of all the available folder within the root folder.
// Get Folder
curl -X GET -H "Authorization: Bearer YOURTOKEN" "https://developer.api.autodesk.com/data/v1/projects/BIM360ACCOUNTID/folders/urn%3Aadsk.wipprod%3Afs.folder%3AYOURROOTFOLDER/contents"
This will give you back a response JSON of all the folder within your Doc Project. Find the ID of the Plans Folder and continue with the following steps using that folder identifier.
//Step 3: Create a storage location
//Step 4: Upload a file to the storage location
//Step 5: Create the first version of the uploaded file
If everything goes correctly you should be able to see your plans in that location now. Please let me know how everything goes with this. Also check that you have the right Scopes setup in your token that the following ones are included scope= account:read account:write
Also that you have the right permissions within your Docs project to upload.
I started messing around with the Google Drive API for ruby (using the google-api-client gem) and I immediately ran into a problem. I can return all the files just fine, but their parents property is nil, even for files that are in a sub folder in my drive. The way I understand it, parents should contain the list of folders that this file resides in. I have full drive scope, so that shouldn't be an issue.
Is this a bug in the gem or am I doing something wrong? The relevant part of the code looks like this :
service = Google::Apis::DriveV3::DriveService.new
service.client_options.application_name = APPLICATION_NAME
service.authorization = authorize
response = service.list_files
response.files.each do |file|
puts "#{file.name} (#{file.parents})"
end
this is my html code to make user to download a file and it is hitting controller
window.location.href="#routes.ListManagementController.downloadList("+listName+")?listname="+listName;
this is my controller code:
String listName = Form.form().bindFromRequest().get("listname");
response().setContentType("application/x-download");
response().setHeader("Content-disposition", "attachment;filename="+listName+"_data_export.csv");
The above two respose() statements make a pop up to download a file I want the browsed file location
File file = new File("C:/csv/" + filename);
So, using servlet api we can write the content into browsed file location using respose.getOutputStream() method. In play there are is no support for servlet. I want browsed file location selected by user so that i can give that location to File and write the file over there.
You can't get the location of a directory on the client, and even if you could, your server side could wouldn't be able to write to it (since it would usually be on a different computer).