Is it possible to convert a Google document to a Word docx file programmatically using Google Script ?
This should work
function myFunction() {
var token = ScriptApp.getOAuthToken();
//Make sure to replace the correct file Id
// Fetch the docx blob
var blb = UrlFetchApp.fetch('https://docs.google.com/feeds/download/documents/export/Export?id=<ID_of_Google_Document>&exportFormat=docx',
{
headers : {
Authorization : 'Bearer '+token
}
}).getBlob();
//Create file in Google Drive
var file = DriveApp.createFile(blb).setName('<name_of_exported_file>.docx');
//Put the file in a drive folder
DriveApp.getFolderById('<FOLDER_ID>').addFile(file);
}
Quoting from this item on the issue tracker...
You can convert a Google Document to docx today using the Drive
Advanced Service:
https://developers.google.com/apps-script/advanced/drive
Here is a small example:
function convertToDocx(documentId) {
var file = Drive.Files.get(documentId);
var url = file.exportLinks['application/vnd.openxmlformats-officedocument.wordprocessingml.document'];
var oauthToken = ScriptApp.getOAuthToken();
var response = UrlFetchApp.fetch(url, {
headers: {
'Authorization': 'Bearer ' + oauthToken
}
});
return response.getBlob();
}
Related
I am trying to send a signature from flutter to a GCP Storage bucket.
Currently, I can send a file to the bucket but it's not openable.
Here is what I am using to get base64 format which I supposed is the intended format to send files.
final data = await _signaturePadKey.currentState!
.toImage(pixelRatio: 3.0);
final image = await data.toByteData(
format: ui.ImageByteFormat.png);
// To send
final base64String =
base64.encode(image!.buffer.asUint8List());
setState(() => {_signatureFile = base64String});
Then I am sending my request as :
Future postOKTrackingSignature(String signature, String projectID) async {
await refreshSTSToken(projectID);
String token = await getSTSToken();
// Headers
var headersData = {
"Authorization": "Bearer $token",
"Content-Type": "image/png"
};
// URL building
var resourcePart =
"XXX";
var paramsData = {
'uploadType': 'multipart',
'name': "${resourcePart}signature.png",
};
var baseURI = 'https://storage.googleapis.com/upload/storage/v1/b/';
String bucketName = "XXX";
var query = paramsData.entries.map((p) => '${p.key}=${p.value}').join('&');
// Body
var bodyData = signature;
final response = await http.post(
Uri.parse("$baseURI$bucketName/o?$resourcePart$query"),
headers: headersData,
body: bodyData);
switch (response.statusCode) {
case 200:
print("$baseURI$bucketName/o?$resourcePart$query");
return {"statusCode": response.statusCode};
default:
print("$baseURI$bucketName/o?$resourcePart$query");
return {"statusCode": response.statusCode, "error": response.body};
}
}
Sadly, I the file got upload but is not usable when I want to get preview, or even download it and try to open it. But while I change the extension to .txt, take the string to : https://base64.guru/converter/decode/file it show me my image a png.
I also tried this :
var dataPrepation = base64.normalize(signature);
var bodyData = "data:image/png;base64,$dataPrepation";
String example :
iVBORw0KGgoAAAANSUhEUgAAA88AAALuCAYAAACQDCTkAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAACAASURBVHic7N3tVRvbti7qd992/y/tCKZ2BEs7AnMiMDcCcyKwTwTTJ4LpHcFkRWBWBJMZgXEE4AiMI+D+KEZTUaiEVCqpPvQ8ralhSwYGGFTqo/fRewIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOD/bw8OSAAAAAAE/X/dj1ABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAs3gD4ySRew2gAAAABJRU5ErkJggg==
Consider Firebase Storage instead of base64; this stackoverflow topic compares the two and outlines the benefits of each.
In light of this, I strongly advise you to continue working on your project utilizing Firebase Storage.
Now, to Upload a file to Cloud Storage, you first create a reference to the full path of the file, including the file name.
// Create a storage reference from our app
final storageRef = FirebaseStorage.instance.ref();
// Create a reference to "mountains.jpg"
final mountainsRef = storageRef.child("mountains.jpg");
// Create a reference to 'images/mountains.jpg'
final mountainImagesRef = storageRef.child("images/mountains.jpg");
// While the file names are the same, the references point to different files
assert(mountainsRef.name == mountainImagesRef.name);
assert(mountainsRef.fullPath != mountainImagesRef.fullPath);
Additionally, I would suggest you review the guide for Firebase Cloud Storage in Flutter written by Dane Mackier.
I have a question on how to change an existing file on SharePoint document library using REST API. I have a couple of files in the location http://site url/<RootFolder>/<SubFolder>/File.docx. I have a UI where it lists all the files from this subfloder location. When the user clicks on edit i am enabling the file name as textbox where the user can change the name of the file.
After doing some research i found that Constructing an endpoint that looks like this: https://<site url>/_api/web/lists/getbytitle('Documents')/items(<item id>) we can edit the file metadata properties. But i could not able to figure out the best way to update the filename of existing document that resides on SharePoint Doc library.
Could someone please help me with the REST API query to fetch the file and the approach to update the filename?
You could consider at least two options:
Option 1. Rename file name
You could update the name of the existing list item as demonstrated below
Example
function rename(webUrl,listTitle,itemId,fileName){
var endpointUrl = webUrl + "/_api/web/lists/getbytitle('" + listTitle + "')/items(" + itemId + ")";
return executeJson(endpointUrl)
.then(function(data){
var itemPayload = {};
itemPayload['__metadata'] = {'type': data.d['__metadata']['type']};
itemPayload['Title'] = fileName;
itemPayload['FileLeafRef'] = fileName;
var itemUrl = data.d['__metadata']['uri'];
var headers = {};
headers["X-HTTP-Method"] = "MERGE";
headers["If-Match"] = "*";
return executeJson(itemUrl,"POST",headers,itemPayload);
});
}
var webUrl = _spPageContextInfo.webAbsoluteUrl; // web url
var listTitle = "Documents"; //list title
var itemId = 1; //list item id
var fileName = "SP User Guide.docx"; //new file name
rename(webUrl,listTitle,itemId,fileName)
.done(function(item){
console.log('Renamed');
})
.fail(function(error){
console.log(error);
});
Option 2. Move file via MoveTo REST endpoint
Example
function moveTo(webUrl,sourceFileUrl,targetFileUrl){
var endpointUrl = webUrl + "/_api/web/getfilebyserverrelativeurl('" + sourceFileUrl + "')/moveto(newurl='" + targetFileUrl + "',flags=1)";
return executeJson(endpointUrl,"POST");
}
var webUrl = _spPageContextInfo.webAbsoluteUrl; // web url
var sourceFileUrl = "/Documents/SP2010.docx";
var targetFileUrl = "/Documents/SP2013.docx";
moveTo(webUrl,sourceFileUrl,targetFileUrl)
.done(function(item){
console.log('Done');
})
.fail(function(error){
console.log(error);
});
executeJson function:
function executeJson(url,method,headers,payload)
{
headers = headers || {};
method = method || 'GET';
headers["Accept"] = "application/json;odata=verbose";
if(method == "POST") {
headers["X-RequestDigest"] = $("#__REQUESTDIGEST").val();
}
var ajaxOptions =
{
url: url,
type: method,
contentType: "application/json;odata=verbose",
headers: headers
};
if(method == "POST") {
ajaxOptions.data = JSON.stringify(payload);
}
return $.ajax(ajaxOptions);
}
You need to use the MoveTo Method to do this as described here in MSDN https://msdn.microsoft.com/en-us/library/office/dn450841.aspx#bk_FileMoveTo.
executor.executeAsync({
url: "<app web url>/_api/SP.AppContextSite(#target)/web
/getfilebyserverrelativeurl('/Shared Documents/filename.docx')
/moveto(newurl='/Other Folder/filename.docx',flags=1)
?#target='<host web url>'",
method: "POST",
success: successHandler,
error: errorHandler
});
I'm trying to simply upload a new blob to an Azure Storage countainer using WebClient like this :
var sas = "[a new generated sas with Read, Write, List & Delete permissions]";
var sData = "This is a test!";
var sEndPoint = "http://myaccount.blob.core.windows.net/mycontainer/MyTest.txt" + sas;
var clt = new WebClient();
var res = await clt.UploadStringTaskAsync(sEndPoint, "PUT", sData);
This is giving me a "(400) Bad Request." error. Am I doing anything wrong here?
Thanks
(By the way, I need to use REST instead of Client API since I'm in a Silverlight project)
You would need to define a request header (x-ms-blob-type) for blob type and set it's value to BlockBlob. Also for Put requests you would need to define the Content-Length request header as well. I wrote a blog post on Shared Access Signatures and performing some blob operations using that (with both REST API and Storage Client library) which you can read here: http://gauravmantri.com/2013/02/13/revisiting-windows-azure-shared-access-signature/.
and here's the code from that post on uploading blob. It uses HttpWebRequest/HttpWebResponse instead of WebClient:
static void UploadBlobWithRestAPISasPermissionOnBlobContainer(string blobContainerSasUri)
{
string blobName = "sample.txt";
string sampleContent = "This is sample text.";
int contentLength = Encoding.UTF8.GetByteCount(sampleContent);
string queryString = (new Uri(blobContainerSasUri)).Query;
string blobContainerUri = blobContainerSasUri.Substring(0, blobContainerSasUri.Length - queryString.Length);
string requestUri = string.Format(CultureInfo.InvariantCulture, "{0}/{1}{2}", blobContainerUri, blobName, queryString);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUri);
request.Method = "PUT";
request.Headers.Add("x-ms-blob-type", "BlockBlob");
request.ContentLength = contentLength;
using (Stream requestStream = request.GetRequestStream())
{
requestStream.Write(Encoding.UTF8.GetBytes(sampleContent), 0, contentLength);
}
using (HttpWebResponse resp = (HttpWebResponse)request.GetResponse())
{
}
}
When testing against the blob emulator this is the code I need to get it working:
var connection = ConfigurationManager.AppSettings["AzureStorageConnectionString"];
var storageAccount = CloudStorageAccount.Parse(connection);
var client = new WebClient();
client.Headers.Add("x-ms-blob-type", "BlockBlob");
client.Headers.Add("x-ms-version", "2012-02-12");
client.UploadData(string.Format(#"{0}/$root/{1}{2}", storageAccount.BlobEndpoint, myFileName, sharedAccessSignature), "PUT", _content);
I am using Azure Media Services and a Silverlight Player to play the streamed url
I am able to ingest, encode the video file as an asset file but when I go play the streamed url I am facing problem.
I use following code to fetch the url...
context = new CloudMediaContext(_accountName, _accountKey);
IAsset myAsset = GetAsset("UUID:7a32b941-30bd-4c96-bf4e-26df5022eec5");
var theManifest = from f in myAsset.AssetFiles
where f.Name.EndsWith(".ism")
select f;
var manifestFile = theManifest.First();
IAccessPolicy streamingPolicy = _context.AccessPolicies.Create("Streaming policy",
TimeSpan.FromDays(10),
AccessPermissions.Read);
ILocator originLocator = _context.Locators.CreateSasLocator(myAsset, streamingPolicy, DateTime.UtcNow.AddMinutes(-500));
GetAssetSasUrlList(myAsset, originLocator);
string urlForClientStreaming = originLocator.Path + manifestFile.Name + "/manifest";
Console.WriteLine("URL to manifest for client streaming: ");
Console.WriteLine(urlForClientStreaming);
this url comes like --
https://mediasvc06w4dq5k8vd08.blob.core.windows.net/asset-064ed2d5-e42d-4c49-98eb-a712db5c614f?st=2012-12-26T23%3A04%3A22Z&se=2013-01-05T23%3A04%3A22Z&sr=c&si=9350bd2f-ec23-40b2-b27a-248bba01b97e&sig=oGgesnr8mXjCdTM5Dz%2FQpFRBDR0g0%2F60ECoXY14EvsA%3DBigBuckBunny.ism/manifest
Its not working .
When I paste this url on browser directly ,I get following error
AuthenticationFailedServer failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:154422cf-822e-4bbc-af2a-fa69273dfb89 Time:2012-12-27T08:57:30.9509847ZSignature fields not well formed.
But if I go and publish asset from portal( www.manage.windowsazure.com )--
I get like following url on protal..
http://mediaervices.origin.mediaservices.windows.net/5edbeae7-c3e6-45c5-bc5c-70f46b526cb5/BigBuckBunny.ism/Manifest
And it works with my silverlight player..
Now problem is that I am not getting url which starts with http from code and the url starting with https is not working with my player.
I guessed that its security issue and tried to host my player in winows azure and tried to player there but no success.
No, not a security issue. You are requesting a SAS url for a Smooth asset, you need an Origin URL. The correct code snippet is here, on my blog:
http://blog-ndrouin.azurewebsites.net/?p=1931
Specifically:
private static string GetStreamingUrl(CloudMediaContext context, string outputAssetId)
{
var daysForWhichStreamingUrlIsActive = 365;
var outputAsset = context.Assets.Where(a => a.Id == outputAssetId).FirstOrDefault();
var accessPolicy = context.AccessPolicies.Create(outputAsset.Name, TimeSpan.FromDays(daysForWhichStreamingUrlIsActive), AccessPermissions.Read | AccessPermissions.List);
var assetFiles = outputAsset.AssetFiles.ToList();
var assetFile = assetFiles.Where(f => f.Name.ToLower().EndsWith("m3u8-aapl.ism")).FirstOrDefault();
if (assetFile != null)
{
var locator = context.Locators.CreateLocator(LocatorType.OnDemandOrigin, outputAsset, accessPolicy);
Uri hlsUri = new Uri(locator.Path + assetFile.Name + "/manifest(format=m3u8-aapl)");
return hlsUri.ToString();
}
assetFile = assetFiles.Where(f => f.Name.ToLower().EndsWith(".ism")).FirstOrDefault();
if (assetFile != null)
{
var locator = context.Locators.CreateLocator(LocatorType.OnDemandOrigin, outputAsset, accessPolicy);
Uri smoothUri = new Uri(locator.Path + assetFile.Name + "/manifest");
return smoothUri.ToString();
}
assetFile = assetFiles.Where(f => f.Name.ToLower().EndsWith(".mp4")).FirstOrDefault();
if (assetFile != null)
{
var locator = context.Locators.CreateLocator(LocatorType.Sas, outputAsset, accessPolicy);
var mp4Uri = new UriBuilder(locator.Path);
mp4Uri.Path += "/" + assetFile.Name;
return mp4Uri.ToString();
}
return string.Empty;
}
I'm trying to use Facebook graph in Chrome extensions, but I'm having trouble in using access token to have permissions. My extension folder has a background.html file with the this code:
function displayUser(user) {
var userName = document.getElementById('userName');
var greetingText = document.createTextNode('Greetings, ' + user.name + '.');
userName.appendChild(greetingText);
}
var appID = "XXXXX";
if (window.location.hash.length == 0) {
var path = 'https://www.facebook.com/dialog/oauth?';
var queryParams = ['client_id=' + appID,'redirect_uri=https://www.facebook.com/connect/login_success.html', 'response_type=token'];
var query = queryParams.join('&');
var url = path + query;
window.open(url);
} else {
var accessToken = window.location.hash.substring(1);
var path = "https://graph.facebook.com/me?";
var queryParams = [accessToken, 'callback=displayUser'];
var query = queryParams.join('&');
var url = path + query;
// use jsonp to call the graph
var script = document.createElement('script');
script.src = url;
document.body.appendChild(script);
}
When I run the extension, it opens a new tab with the app authorization. When I accept it, it just says "Success" and the url of this tab is like this:
https://www.facebook.com/connect/login_success.html#access_token=AAABtoJwdQQgBAP8KK6QYmlQ1CJOSjQxWjXoa7qgUthF507BGPgLeWEplB87fZBpDZBZBd7CKoIWb4Fa3S2laBuZAUf795p1N3QZDZD&expires_in=5549
So now how can I use this access token in background.html and close that authorization tab?
You should watch (in the extension code) for the tab changes with success url like this
chrome.tabs.onUpdated.addListener(onTabUpdated);
Then the handler function:
function onTabUpdated(tabId, changeInfo, tab) {
if (changeInfo.url && changeInfo.url.indexOf(SUCCESS_URL) == 0) {
// extract access token from url
Extract function:
function accessTokenFromSuccessURL(url) {
var hashSplit = url.split('#');
if (hashSplit.length > 1) {
var paramsArray = hashSplit[1].split('&');
for (var i = 0; i < paramsArray.length; i++) {
var paramTuple = paramsArray[i].split('=');
if (paramTuple.length > 1 && paramTuple[0] == 'access_token')
return paramTuple[1];
}
}
return null;
}
Judging by redirect_uri=https://www.facebook.com/connect/login_success.html, I'm assuming you're building a desktop or a client side app.
Try adding var RedirectURI = window.location;
And change the redirect URI in the queryParams array to redirect_uri= RedirectURI
If required, you can add http://localhost to the Site URL entry in https://developers.facebook.com/apps
Once the token is obtain, it is redirected to your previous page with the authorization token added as a hash which is automatically handled by the else { } block in your code.