// handles saving the audio file to drive
function
invokeSave(dataURI, filename){
var
blob = dataURItoBlob(dataURI, filename);
var
file = DriveApp.createFile(blob);
return
file.getUrl();
}
function
dataURItoBlob(dataURI, filename) {
// convert base64/URLEncoded data component to raw binary data held in a string
var
byteString;
if
(dataURI.split(
','
)[0].indexOf(
'base64'
) >= 0){
byteString = Utilities.base64Decode(dataURI.split(
','
)[1]);
}
else
{
byteString = decodeURI(dataURI.split(
','
)[1]);
}
// separate out the mime component
var
mimeString = dataURI.split(
','
)[0].split(
':'
)[1].split(
';'
)[0];
return
Utilities.newBlob(byteString, mimeString, filename);
}
invokeSave(datajson, 'YOUR FILE NAME');
VÕ TỰ ĐỨC | |||||
CEO | |||||
088.888.3458 | |||||
Sàn gỗ Tự nhiên | Sàn gỗ Ngoài trời | Sàn gỗ Công nghiệp | Cầu Thang | Nội thất Thú Cưng |
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-script-community.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/02cfa9e0-f0fd-48ff-ab17-f47d90f247f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.
var response = UrlFetchApp.fetch ( endPoint, options );
var datajson = JSON.parse(response); // based64 audio
var folderID = "XXXXYYYY"; /// my folder ID on Google Drive.
var driveFolder = DriveApp.getFolderById(folderID);
var filename = "name_of_newfile";
var filecontent = {
mimeType: 'application/json; charset=utf-8',
content: datajson, //datajson
};
var file = driveFolder.createFile(filename, datajson);
var folderID = "XXXXYYYY"; /// my folder ID on Google Drive. var driveFolder = DriveApp.getFolderById(folderID);
var filename = "name_of_newfile";
var byteString = Utilities.base64Decode(datajson); var blob = Utilities.newBlob(byteString, "audio/mp3", filename ); var file = driveFolder.createFile(blob);
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/ba62b0d6-c0b3-462e-8071-11672ae4ae6bn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/41e0ff24-3ef0-47c8-b7ad-e379cfdd2fa5n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/1ddcb06c-7d36-4f22-9843-c245831ae405n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/ac1d7b32-f3c1-4a49-a7d3-94193840b615n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/bd9b6945-c54e-43e6-a293-7f8496e6dae3n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/6e34b177-87d8-479d-a16b-f14ff2db2611n%40googlegroups.com.