Delete and Rename events in google drive - google-app-engine

I am working on a feature for our webapp where we create google drive files from our server
Drive service = getServiceForLoginUser();
com.google.api.services.drive.model.File fileMetadata = new com.google.api.services.drive.model.File();
fileMetadata.setTitle(getDefaultName());
fileMetadata.setMimeType(APPLICATION_VND_GOOGLE_APPS_DRIVE_SDK);
com.google.api.services.drive.model.File.Thumbnail thumbnail = buildThumbnail(driveType);
fileMetadata.setThumbnail(thumbnail);
com.google.api.services.drive.model.File googleFile = service.files().insert(fileMetadata)
.setFields("id")
.execute();
I have configured Drive UI Integration to trigger New and Open URL flows from google drive.I have also published a chrome app with following manifest.
"name" : "classflowtest",
"version" : "3.5",
"manifest_version" : 2,
"icons": {
"128": "icon_128.png"
},
"description" : "description_text",
"container" : "GOOGLE_DRIVE",
"api_console_project_id" : "146081768739",
"gdrive_mime_types": {
"http://drive.google.com/intents/opendrivedoc": [
{
"type": ["image/png", "image/jpeg", "image/gif", "html","application/vnd.google.drive.ext-type.png",
"application/vnd.google.drive.ext-type.jpg","application/vnd.google.drive.ext-type.gif","application/vnd.google.drive.ext-type.html"],
"href": "https://mywebappurl",
"title" : "Open",
"disposition" : "window"
}
]
},
"app" : {
"launch" : {
"web_url" : "mywebappurl"
}
}
So now I can trigger New and Open flows in drive successfully. In New flow I create first a resource in our db and then I create a file in google drive from my application server. So every entry I create in google drive has a representation in our db as well. My issue is now if I rename or delete the file in google drive how do I get those events so that I can make the necessary changes in our DB ?

Check the Changes: list if it can help you. It will lists all the changes in your drive. But is is difficult to filter the results. To get the deleted files, you must specify the includeRemoved parameter to true. So it is easier to get the files if you know its fileID before you rename or delete it.
I found in this SO question that someone use Apps Activity API to solve this problem.
For more information, check this thread.

Related

How do I access and view the image present in my Laravel's storage folder in a React form?

I have few images in my storage folder(laravel), I want to view them in my React data table. Apparently it only displays the path name of the image.
First you have create symbolic link
php aritsan storage:link
this will create shortcut storage folder in public folder
so you can access url
https:://urdomain/storage/filename
Here i assume your images of files exist in storage/app/public.If your files contain in any subfolder then it should be
https:://urdomain/storage/subfoldername/filename.extension
ref:https://laravel.com/docs/8.x/filesystem#the-public-disk
Also in reactjs if you are getting json response like this
{
"id": 23532,
"name": "john",
"image": "images/image.jpeg",
},
then you might need to append baseurl
<img src="https:://urdomain/storage/{image}" alt='image' width='100%'/>
Also you refer this answer :
Image not showing from Django rest api in Reactjs

Recover Vsphere VMs by folder with postman request?

I try to recover each VM by folder by using request from postman.
With this request, I'm able to list each folder in my vsphere :
GET https://SERVER/rest/vcenter/folder
With this second command, I'm able to list each VM in my vpshere :
GET https://SERVER/rest/vcenter/vm
I want to know if there is a way to get a folder and each VMS inside it ?
Something like :
GET https://SERVER/rest/vcenter/folder/my_folder
With an output like :
"value": [
{
"folder": "XXX",
"VMs" : {
VM1
VM2
...
Or someting like that ?
Thanks a lot !
http://vmware.github.io/vsphere-automation-sdk-rest/6.5/operations/com/vmware/vcenter/folder.list-operation.html
&filter.parent_folders.1=obj-103
it supports query parameter parent_folders , so the url will be like
GET https://SERVER/rest/vcenter/folder?filters.filter.parent_folders.1=obj-103
Even VM supports the filter called folder:
http://vmware.github.io/vsphere-automation-sdk-rest/6.5/operations/com/vmware/vcenter/vm.list-operation.html

How to get notification from google drive sheet on edit?

I want to send notification to third party application when someone make changes in document stored in google drive.
can someone please help me that how to bound script with any document and when someone make changes in that script should run and send notification to third party application.
I have tried the following code But it is not working.
function onEdit(event){
var sheet = event.source.getActiveSheet();
var editedRow = sheet.getActiveRange().getRowIndex();
var editedolumn = sheet.getActiveRange().getColumnIndex();
var values = sheet.getSheetValues(editedRow, editedolumn, 1, 6);
Logger.log(values);
getSession();
}
function getSession(){
var payload =
{
"username" : "username",
"password" : "password",
};
var options =
{
"method" : "post",
"payload" : payload,
"followRedirects" : false
};
var login = UrlFetchApp.fetch("https://abcd.service-now.com/nav_to.do?uri=login.do" , options);
Logger.log(login);
var sessionDetails = login.getAllHeaders()['Set-Cookie'];
Logger.log(sessionDetails);
sendHttpPost(sessionDetails);
}
function sendHttpPost(data) {
var payload = {"category" : "network","short_description" : "Test"};
var headers = {"Cookie" : data}
var url = 'https://abcd.service-now.com/api/now/table/incident';
var options = {'method': 'post','headers': headers,'payload': payload,'json': true};
var response = UrlFetchApp.fetch(url, options);
Logger.log(response.getContentText());
}
To send notification to third party application when someone make changes in document stored in google drive
Based from this Google Drive Help Forum, this feature hasn't been added yet. However, you may set notifications in a spreadsheet to find out when there's some modifications done in your spreadsheet. To set notifications in a spreadsheet:
Open the spreadsheet where you want to set notifications.
Click Tools > Notification rules.
In the window that appears, select when and how often you want to
receive notifications.
Click Save.
And, to bound script with any document
You may find the complete guide in Scripts Bound to Google Sheets, Docs, or Forms documentation. As mentioned,
To create a bound script, open a Google Sheets, Docs, or Forms file, then select Tools > Script editor. To reopen the script in the future, do the same thing. Because bound scripts do not appear in Google Drive, that menu is the only way to find or open the script.

DreamFactory: How to upload an image to the fileserver and save the path of the image in DataBase?

I'm thinking about using DreamFactory as API. I'm fresh in serversice-logic. I want to store an image on the filesystem and the path of the stored file into a database. I won't store the image as blob inside the database, because their will be many other images following. Can anybody please point me into the right direction?
First post the image to the filesystem using:
post /files/{file_path}
And after that:
post /mysql/_table/{table_name} createRecords() - Create one or more records
But how to pass the path to the database?
One way would be to use server-side scripting (V8Js in this case) on the POST to /files/{file_path}. Go to the Admin application, Scripts tab, and work your way through the events to the following path...
Process Event Scripts > files > files.{file_path} > [POST] files.{file_path} > files.{file_path}.post.post_process
Try the following script...
// event.resource is the {file_path} part,
// including any folders from root, i.e. my/path/file.txt
var_dump(event.resource);
// Create a record that you want to post to a table,
// using the "todo" table for example, setting "name" to the file path
// "mysql" is my db service name
var record = {"resource": [ {"name": event.resource, "complete": false } ] };
var result = platform.api.post('mysql/_table/todo', record);
var_dump(result);
// result contains a resource array with the id of the record created
// like {"resource": [ {"id": 5} ] }

How to generate ready-for-web-server source?

I'm trying to find a way to generate (with generate.py source-all) application code that is ready for running from web server (eg. Tomcat).
The only thing that prevents me from doing this is the fact that myapp.js contains filesystem URIs in libinfo object:
var libinfo = {
"__out__":{"sourceUri":"script"},
"myapp":{"resourceUri":"../source/resource","sourceUri":"../source/class"},
"qx":{
"resourceUri":"file:///C:/dev/qooxdoo-5.0.1-sdk/framework/source/resource",
"sourceUri":"file:///C:/dev/qooxdoo-5.0.1-sdk/framework/source/class",
"sourceViewUri":"https://github.com/qooxdoo/qooxdoo/blob/%{qxGitBranch}/framework/source/class/%{classFilePath}#L%{lineNumber}"
}
};
When I manually change resourceUri & sourceUri from
file:///C:/dev/qooxdoo-5.0.1-sdk/framework/source/...
to
/myapp/qooxdoo-5.0.1-sdk/framework/source/...
application page successfully loads in the browser with all the dependencies (generated sources are already in document root, and "qooxdoo-5.0.1-sdk" framework content loads due to the mapping /myapp/qooxdoo-5.0.1-sdk => C:\Dev\qooxdoo-5.0.1-sdk set up on the server).
Is there a way to tell generate.py that my SDK framework files should be accessed through an URL (/myapp/qooxdoo-5.0.1-sdk/...) instead of filesystem URI?
(I can see there are a number of "compile-options" that can be specified in config.json (qooxdoo Documentation Release 5.1: chapter 11.3.3 - Generator Config Keys), but looks like none of them solves the problem)
In your config.json you will have a "jobs" section containing a "libraries" section, containing a "library" array - your application is a library, as is Qooxdoo, as is any contribs so it will look something like this:
"jobs" : {
"libraries" : {
"=library" : [ {
"manifest" : "${QOOXDOO_PATH}/framework/Manifest.json"
}, {
"manifest" : "Manifest.json"
}
},
Each "library" object can have a "uri" property, so for your example you probably want something like this:
"jobs" : {
"libraries" : {
"=library" : [ {
"manifest" : "${QOOXDOO_PATH}/framework/Manifest.json",
"uri" : "/some/other/uri/qooxdoo-5.0.1-sdk"
}, {
"manifest" : "Manifest.json"
}
},
and then on your web server, either position the qooxdoo-5.0.1-sdk directory appropriately or create a mapping to it.

Resources