Reputation: 77
I want to open (read an write) files like how google drive works. But I don't know how implement this. I thought it is possible with share link which I have done in one-drive. If anybody have an idea please share with me thanks.
Upvotes: 0
Views: 1751
Reputation: 6791
Use the property alternateLink
alternateLink
- A link for opening the file in a relevant Google editor or viewer.
Java Script sample Code:
/**
* Print a file's metadata.
*
* @param {String} fileId ID of the file to print metadata for.
*/
function printFile(fileId) {
var request = gapi.client.drive.files.get({
'fileId': fileId
});
request.execute(function(resp) {
console.log('Title: ' + resp.title);
console.log('Description: ' + resp.description);
console.log('MIME type: ' + resp.mimeType);
console.log('Alternative link: '+resp.alternateLink)
});
}
Use the property webViewLink
webViewLink
- A link for opening the file in a relevant Google editor or viewer in a browser.
Java Script sample Code:
/**
* Print files.
*/
function listFiles() {
var request = gapi.client.drive.files.list({
'pageSize': 10,
'fields': "nextPageToken, files(id, name, webViewLink)"
});
request.execute(function(resp) {
appendPre('Files:');
var files = resp.files;
if (files && files.length > 0) {
for (var i = 0; i < files.length; i++) {
var file = files[i];
appendPre(file.name + ' (' + file.id + ')' + file.weblink);
}
} else {
appendPre('No files found.');
}
});
}
In v3, field parameter
is used to get the desired property of the file.
Upvotes: 1