2019의 게시물 표시

Preorder Copy Android App

이미지
doGet Parameters in Apps Script 에 이어서 Pre-order copy 앱을 안드로이드에서 사용할 수 있도록 만들었습니다. Google Play에서 앱을 찾아서 설치할 수 있습니다. Preorder Copy Android App https://play.google.com/store/apps/details?id=com.eojji.preordercopy Preorder Copy Android App.png

doGet Parameters in Apps Script

이미지
Apps Script로 Web App을 만들 때 doGet함수의 매개 변수 e는 event object입니다. Web Apps https://developers.google.com/apps-script/guides/web Request Parameters e.parameter : An object of key/value pairs that correspond to the request parameters. Only the first value is returned for parameters that have multiple values. Query string https://en.wikipedia.org/wiki/Query_string Pre-order copy 앱의 doGet 함수에 src parameter를 추가했습니다. 이것은 사용자가 앱의 Source 입력 상자에 문자열을 입력하고 Copy 버튼을 클릭하는 것과 같습니다. src Parameter 기능을 확인하기 위해서 파일을 복사해 보겠습니다. EOJJI Why and How logo.png Google 드라이브에 있는 이 파일의 URL은 다음과 같습니다. https://drive.google.com/file/d/0B_MA3GXgQ1ulX2h3aF9YSnNSUzQ/view Pre-order copy 앱 실행 URL은 다음과 같습니다. https://script.google.com/macros/s/AKfycbzIf1xfQ7HH1SSQdR_LCFTtR-YrajOrv1RysWDzu8eUyKdumQE/exec Pre-order copy 앱 실행 URL 뒤에 ?src=를 적고 EOJJI Why and How logo.png 파일 URL을 덧 붙입니다. https://script.google.com/macros/s/AKfycbzIf1xfQ7HH1SSQdR_LCFTtR-YrajOrv1R

Create web apps for Android devices

이미지
Android 기기용 웹 앱 만들기 Apps Script로 만든 웹 앱을 Android 기기에서 사용할 수 있도록 Google Play에 게시할 수 있습니다. Copy Google drive folder App https://copy.gfolder.net/ Create web apps for Android devices https://support.google.com/a/answer/9187142 You can use the Google Admin console to publish web apps to managed Google Play. A web app is an Android app that you create using a website address (URL), icon image, and title. When a user opens a web app on their device, the app’s URL opens in Chrome Browser. Web apps are only available to users in your organization and can’t be made public. You distribute them to your users just like other Android apps. Create and manage web apps through the Admin console https://gsuiteupdates.googleblog.com/2018/12/create-manage-web-apps-in-g-suite.html Deploy Google Apps Script web app as an Android application https://www.kutil.org/2019/01/deploy-google-apps-script-web-app-as.html Chrome Custom Tabs

Files in Google Drive

Advanced Drive Service in Apps Script 에 이어서  Files and folders overview 를 보면 파일 속성 중에 ID가 있습니다. File attributes File ID A unique opaque ID for each file. File IDs are stable throughout the life of the file, even if the file name changes. Files in Drive cannot be directly addressed by their path. Search expressions are used to locate files by name, type, content, parent container, owner, or other metadata. 제가 만든 복사 앱은 파일이나 폴더 URL을 입력 받아서 복사본을 만듭니다. 참고:  G 폴더 복사 앱 설명서 파일을 복사하기 위해서 drive.files.copy를 사용합니다. 이때 Parameter에 file Id를 넣어줘야 합니다. Files: copy 를 참고하세요. 따라서 파일이나 폴더 URL에서 파일 ID를 추출해야합니다. 예전에 stackoverflow에서 검색해서 코드에 적용했는데 조금 바뀌었네요. Easiest way to get file ID from URL on Google Apps Script https://stackoverflow.com/questions/16840038/easiest-way-to-get-file-id-from-url-on-google-apps-script/16840612 function getIdFromUrl(url) {   return url.match(/[-\w]{25,}/); } 마지막에 있는 ID를 구하기 위해서 $를 추가했네요. /[-\w]{25,}$/ $를 추가하면 파일 ID뒤에 따라오는(/edit)

Advanced Drive Service in Apps Script.

Writes Apps Script errors in this spreadsheet 에 이어서 Google Apps Script로 Web App을 만들면서 try ... catch를 사용했습니다. 오류가 나면 Error 객체를 반환하는데 이때까지 name과 message만 사용해서 오류를 처리했습니다. message에 있는 문자열이 뭔가에 따라서 처리했는데 하면서도 이건 아니다 생각했었죠. Google Apps Script에서  Google Drive API 를 사용할 수 있도록  Advanced Drive Service 를 제공합니다. 다음은 Google Drive API에서 제공하는 오류입니다. Resolve errors https://developers.google.com/drive/api/v2/handle-errors {   "error": {     "errors": [       {         "domain": "global",         "reason": "badRequest",         "message": "Bad Request"       }     ],     " code ": 400,     "message": "Bad Request"   } } {   "error" : {     "errors" : [       {         "domain" : "global" ,         "reason" : "badRequest" ,         "message" : "Bad Request&q

Writes Apps Script errors in this spreadsheet.

이미지
저는 Apps Script로 앱을 만듭니다. https://www.eojji.com/app Google Drive REST API를 사용하는데 다양한 오류가 발생합니다. 다른 분들과 공유하기 위해서 스프레드시트에 기록 중입니다. https://docs.google.com/spreadsheets/d/1p-saNPVWm1ZTBtryYkxY8rL0wk_pQClM5xThogaHtBs/edit?usp=sharing Writes Apps Script errors in spreadsheet.png 이 시트에 기록할 내용이 있으면 보내 주세요. 개발에 반영하겠습니다. https://hi.eojji.com/ 만약 파일 복사 API 호출에서 발생한 오류가 일시적이면 지수적 감속으로 다시 시도합니다.   if (resp.name == 'HttpResponseException' ||       resp.message.indexOf('Internal Error') >= 0 ||       resp.message.indexOf('Backend Error') >= 0 ||       resp.message.indexOf('Transient failure') >= 0 ) {           copiedState.check = '-2'; // 지수적 감속 참고: Deduper Resolve Errors, Exponential backoff https://eojji.blogspot.com/2019/06/deduper-resolve-errors-exponential.html Resolve errors - Google Drive API https://developers.google.com/drive/api/v2/handle-errors Troubleshooting https://developers.google.com/app

Copy to shared drives app

이미지
Copy to shared drives app manual Google 드라이브 Folder 복사 앱 설명서를 수정했습니다. https://docs.google.com/document/d/1rM01Sp_X6oCfTyTDyR8drUkucErI7iVezIM2FiR-B6U/edit?usp=sharing Web page https://copy.gfolder.net/ 앱 실행 URL bit.ly/GFolder 팀 드라이브와 공유 드라이브가 공존하고 있습니다. Team Drives is being renamed to shared drives https://gsuiteupdates.googleblog.com/2019/04/shared-drives.html Copy to shared drives app, 2019-06-21.png 앱에 추가된 기능이 있습니다. 모든 폴더에서 분리된 파일을 찾을 수 있습니다. https://cafe.naver.com/eojji/547 https://cafe.naver.com/eojji/548 파일 업로드 https://blog.naver.com/gsuite-reseller/221554030898

Deduper Resolve Errors, Exponential backoff

Remove Duplicate files in Google Drive 에 이어서 Apps script로 구글 드라이브 API를 호출하는데 구글 서버 오류가 발생하면 그냥 종료합니다. 앱 사용자가 로그 스프레드시트를 보고 중단된 이유에 따라 Find 버튼을 클릭할 수 있습니다. 서버 오류를 처리하기 위해서 ... Error GoogleJsonResponseException 다음 오류로 인해 drive.files.list API를 호출하지 못했습니다. Internal Error GoogleJsonResponseException 다음 오류로 인해 drive.parents.insert API를 호출하지 못했습니다. Backend Error 오류를 해결하기 위해서 찾아보니 Exponential backoff를 권장합니다. Resolve errors https://developers.google.com/drive/api/v2/handle-errors 500: Backend error An unexpected error occurred while processing the request. Retry failed requests to resolve errors https://developers.google.com/drive/api/v3/handle-errors#exponential-backoff You can periodically retry a failed request over an increasing amount of time to handle errors related to rate limits, network volume, or response time. For example, you might retry a failed request after one second, then after two seconds, and then after four seconds. This method, cal

Remove Duplicate files in Google Drive

이미지
Google 드라이브에서 중복 파일 제거하기 구글 드라이브에서 파일 크기가 큰 거부터 읽어서 같은 파일이 있는지 검사합니다. 같은 파일이면 파일을 만든 순서대로 스프레드시트에 기록합니다. 같은 파일 중에서 최초로 만든 파일을 제외한 나머지 파일들을 특정 폴더에 추가합니다. 모든 파일의 중복 검사가 끝나면 이 폴더를 삭제하고 휴지통까지 비우면 중복 파일 제거가 끝납니다. DeduperTrigger_sheet.png 작업은 6분 주기로 실행됩니다. 한번 실행한 결과를 로그 스프레드시트에 기록합니다. Count: 274 / 2000 이것은 한번 실행할 때 2,000개 파일을 읽었고 그 중에서 중복 파일 274개를 찾아서 폴더에 추가했음을 뜻합니다. Drive Sheet App 실행 URL https://script.google.com/macros/s/AKfycbzJcy6zIAdI46QNFrY8JzhqpT2ZeJ2x9d2mxlzX2yDnlVSR8hw/exec 앱 개발 과정은 다음을 참고하세요. Duplicate files, Deduper in Google Drive Find the same file with md5 in Drive.Files.list Move duplicate files to the trash. Deduper in Drive Sheet app

Deduper in Drive Sheet app

이미지
Move duplicate files to the trash 에 이어서 중복된 파일을 휴지통 대신 특정 폴더에 넣기 위해서 Drive.Parents.insert를 사용했습니다. Parents: insert Adds a parent folder for a file https://developers.google.com/drive/api/v2/reference/parents/insert 내 드라이브에서 중복된 파일을 찾아서 원본만 남기고 나머지 파일을 '_ Deduper eojji' 폴더에 추가합니다. var folderName = '_ Deduper eojji'; 중복 파일 찾기가 완료되면 Deduper Spreadsheet의 B1 셀이 Completed로 변합니다. Deduper 폴더에서 필요없는 파일을 삭제합니다. Deduper 폴더를 삭제해도 됩니다. Deduper 폴더는 중복 파일 찾기를 위해서 Find 버튼을 클릭하면 만들어집니다. 저장 공간을 늘리기 위해서 휴지통을 비웁니다. Google 드라이브에 있는 파일 삭제 및 복원하기 https://support.google.com/drive/answer/2375102 Google 드라이브 공간 비우기 및 저장용량 늘리기 https://support.google.com/drive/answer/6374270 Drive Sheet App Drive Sheet App을 실행하기 위한 URL입니다. https://script.google.com/macros/s/AKfycbzJcy6zIAdI46QNFrY8JzhqpT2ZeJ2x9d2mxlzX2yDnlVSR8hw/exec Deduper in Drive Sheet app.png 중복 파일 찾기 작업을 시작하려면 앱 화면에서 Find 버튼을 클릭합니다. 작업을 삭제하려면 Delete 버튼을 클릭하세요. 주의: Search 작업도 같이 삭제됩니다. Lo

Move duplicate files to the trash.

이미지
Find the same file with md5 in Drive.Files.list 에 이어서 배열에 있는 파일 객체에서 md5Checksum 속성이 같은 것만 추출하려고 이것 저것 알아 봤습니다. 배열의 필터나 map을 사용하면 된다고하는데 제 작업에는 맞지 않습니다. 제약 사항으로 Drive.Files.list로 한번에 모든 파일을 읽어 올 수 없습니다. 스크립트 실행시간이 최대 6분이라 그 전에 작업 환경을 저장해 두고 트리거로 쿼리 작업을 호출해야 합니다. md5 속성이 같은 것만 추출하기 위해서 쿼리한 파일 목록에서 파일 하나를 읽어서 저장해 둡니다. 그리고 다음 파일을 하나씩 가져와서 비교합니다. 가져온 파일이 저장한 파일과 다르면 저장 파일에 가져온 파일을 대입하고 다음 파일을 읽습니다. md5가 같으면 저장된 파일과 읽은 파일 둘을 스프레드시트에 기록합니다. 다음부터 파일이 같으면 가져온 파일만 스프레드시트에 기록합니다. 어제 Find 버튼을 클릭해서 만들어진 스프레드시트입니다. Deduper Spreadsheet 1560830988322.png 로그 스프레드시트를 보고 구글 서버의 내부 오류가 있었을 때 Find 버튼을 눌러서 계속 작업을 시켰습니다. 마지막 행에 Start가 기록된 상태로 멈춰있습니다. Start 다음에 Continue나 Error가 나와야하는데 없는 걸 보니 작업이 중단된 상태입니다. Log Search 1558768360813.png 구글 서버의 하루 할당량 제한이 초기화되려면 24시간 기다려야 됩니다. 그 후에 Find 버튼을 클릭하면 작업이 계속될 겁니다. 이제 스프레드시트에 중복된 파일을 모으는 기능은 완료된 것 같습니다. 다음으로 할 일은 중복된 파일 중에서 가장 먼저 생성된 파일만 남기고 나머지는 삭제하면 됩니다. 중복된 파일을 바로 삭제하면 복구가 어렵습니다. 휴지통을 거쳐서 삭제하면 안전한데 휴지통은 이미 다른 파일이 있어서 중복된

Find the same file with md5 in Drive.Files.list

이미지
Duplicate files, Deduper in Google Drive 에 이어서 drive.files.list로 쿼리한 결과를 스프레드시트로 출력합니다. 구글 드라이브에 같은 파일을 업로드해서 md5가 같은 걸 확인했습니다. Deduper Spreadsheet.png Files: list를 사용해서 'quotaBytesUsed' 속성이 큰 순서로 파일 목록을 만듭니다. 'md5Checksum'이 같으면 같은 파일로 간주해서 다른 스프레드시트에 기록할 생각입니다. Drive Sheet app을 실행해 보려면 다음을 참고하세요. https://drive.eojji.com/sheet Files: list https://developers.google.com/drive/api/v2/reference/files/list G Suite Developer Drive REST v2 참조 Lists the user's files. Try it now or see an example. This method accepts the q parameter, which is a search query combining one or more search terms. For more information, see the Search for files guide. Response If successful, this method returns a response body with the following structure: {   "kind" : "drive#fileList" ,   "etag" : etag ,   "selfLink" : string ,   "nextPageToken" : string ,   "n

Duplicate files, Deduper in Google Drive

이미지
내 구글 드라이브에는 많은 파일이 있습니다. https://drive.google.com/drive/my-drive storage drive.google.com drive my-drive.png 주로  Drive cse app으로 동영상을 찾아서 G 폴더 복사 app으로 팀 드라이브에 복사합니다. 팀 드라이브는 공유 드라이브로 이름을 바꾸는 중입니다. 복사가 완료되면 팀 드라이브의 폴더를 내 드라이브로 옮깁니다. 이렇게 공유 드라이브를 거치는 이유는 구글 서비스 할당량 때문에 복사가 중단될 수 있고 이때 같은 공유 드라이브의 멤버 계정으로 로그인해서 이어서 복사할 수 있기 때문입니다. 자세한 내용은 복사 앱 설명서 를 참고하세요. Quotas for Google Services Apps Script | Google Developers https://developers.google.com/apps-script/guides/services/quotas Apps Script services impose daily quotas and hard limitations on some features. If you exceed a quota or limitation, your script throws an exception and execution terminates. 복사하기 전에 내가 가지고 있는 파일인지 확인하기 위해서 Drive sheet app에서 파일명으로 검색해서 확인할 수 있지만 귀찮은 일입니다. 구글 드라이브에 내가 가진 파일을 크기순으로 정렬해서 볼수있는 기능이 있습니다. 단순히 인터넷 브라우저에서 구글 드라이브 사이트로 이동해서 저장용량을 클릭하면 됩니다. 위에 있는 이미지에서 저장용량의 위치를 확인하세요. Clear Google Drive space & increase storage https://support.google.com/drive/answer/6374270 G

About: get - Google Drive APIs

이미지
About - Google Drive APIs https://developers.google.com/drive/api/v2/reference/about https://developers.google.com/drive/api/v2/reference/about/get /**  * Print information about the current user along with the Drive API  * settings.  */ function printAbout() {   var request = gapi.client.drive.about.get();   request.execute(function(resp) {     console.log('Current user name: ' + resp.name);     console.log('Root folder ID: ' + resp.rootFolderId);     console.log('Total quota (bytes): ' + resp.quotaBytesTotal);     console.log('Used quota (bytes): ' + resp.quotaBytesUsed);   }); } Copy Google drive folder App https://copy.gfolder.net/

ASKfm - Anonymous SNS

https://ask.fm/ Community Guidelines https://safety.ask.fm/community-guidelines/ Eojji ASKfm https://ask.fm/eojji 참고 ASKfm - 나무위키 https://namu.wiki/w/ASKfm Ask.fm - Wikipedia https://en.wikipedia.org/wiki/Ask.fm 익명성의 순기능, 솔직한 피드백 등 https://kblog.popekim.com/2019/06/blog-post_10.html '에스크 저격'을 아십니까…욕설과 비방으로 얼룩지는 익명 SNS http://news.chosun.com/site/data/html_dir/2015/02/23/2015022302343.html 질문자는 에스크에 따로 가입하지 않더라도 익명으로 자유롭게 질문할 수 있다.

이메일을 사용하여 blogger에 글 게시하기

이메일을 사용하여 게시 Mail2Blogger라고도 합니다. 이 주소를 사용하여 최대 10MB의 텍스트와 이미지를 블로그에 바로 게시할 수 있습니다. 글 작성, 수정 또는 삭제 이메일로 글 게시 이메일 제목을 글 제목으로 하여 이메일을 작성합니다. 이메일의 본문이 글의 내용이 됩니다. . 글의 맨 끝에   #end를 입력합니다. . 이미지를 포함하려면 이메일에 이미지를 첨부합니다. 내가 만든 이메일 주소(사용자 이름.[독특한 단어]@ blogger.com )로 이메일을 전송합니다. 참고: 내가 만든 독특한 이메일 주소로 이메일을 전송하는 모든 사용자는 나를 가장하여 내 블로그에 글을 게시할 수 있습니다.