{"_id":"546469f0f42a472000b0c4b7","is_link":false,"version":{"_id":"54523fec04160008005b1ccb","project":"54523fec04160008005b1cc8","__v":3,"createdAt":"2014-10-30T13:41:00.515Z","releaseDate":"2014-10-30T13:41:00.515Z","categories":["54523fec04160008005b1ccc","546458255871e90800f5014e","56117ff28c76a61900fd06d5"],"is_deprecated":true,"is_hidden":false,"is_beta":false,"is_stable":false,"codename":"","version_clean":"1.0.0","version":"1.0"},"__v":4,"user":"54523f0604160008005b1cc0","category":{"_id":"546458255871e90800f5014e","__v":5,"pages":["546467902c77331a00252bb8","54646990f42a472000b0c4b2","546469adf42a472000b0c4b4","546469f0f42a472000b0c4b7","546a2a51a3b67a0e00559c18"],"version":"54523fec04160008005b1ccb","project":"54523fec04160008005b1cc8","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-11-13T07:05:09.147Z","from_sync":false,"order":0,"slug":"rollmyfile-javascript-api","title":"rollMyFile JavaScript API"},"project":"54523fec04160008005b1cc8","githubsync":"","updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-11-13T08:21:04.098Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"try":true,"basic_auth":false,"results":{"codes":[]},"settings":"","auth":"never","params":[],"url":""},"isReference":false,"order":5,"body":"Key method of rollMyFile API – given the URL to download a file open it online with one of the applications on rollApp.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"rollMyFile.openFileByUrl(\\\"http://www.example.com/documentation/overview.docx\\\");\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nWith this call application will open in a separate window with the file loaded into it.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Pop-up Blocker\",\n  \"body\": \"To prevent pop-up blocker from interfering with application launch this method has to be called from an event handler for click or key press.\\n\\nMore about pop-up blocker [from Mozilla developers][0].\\n\\n[0]: https://support.mozilla.org/en-US/kb/pop-blocker-settings-exceptions-troubleshooting\"\n}\n[/block]\nIf you need better visibility into the result of the operation, for example, to show custom error message, when opening a file fails, you can supply `onerror` and `onsuccess` to *openFileByUrl*:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Callback\",\n    \"h-1\": \"Description\",\n    \"0-0\": \"onerror\",\n    \"1-0\": \"onsuccess\",\n    \"0-1\": \"Called when attempt to open a file failed for any reason.\",\n    \"1-1\": \"Called after the file was opened successfully.\"\n  },\n  \"cols\": 2,\n  \"rows\": 2\n}\n[/block]\nThe application to open the file is determined using file name deduced from the URL. However, that would not work, if URL does not contain name of the file. In this case you can explicitly pass name of the file to *openFileByUrl* like this:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"rollMyFile.openFileByUrl(\\n  {\\\"url\\\": \\\"http://www.example.com/file/12345678\\\",\\n   \\\"name\\\": \\\"overview.docx\\\"});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"rollmyfile-js-openfilebyurl","type":"fn","title":"openFileByUrl(url or file_data, onerror, onsuccess)"}

openFileByUrl(url or file_data, onerror, onsuccess)


Key method of rollMyFile API – given the URL to download a file open it online with one of the applications on rollApp. [block:code] { "codes": [ { "code": "rollMyFile.openFileByUrl(\"http://www.example.com/documentation/overview.docx\");", "language": "javascript" } ] } [/block] With this call application will open in a separate window with the file loaded into it. [block:callout] { "type": "warning", "title": "Pop-up Blocker", "body": "To prevent pop-up blocker from interfering with application launch this method has to be called from an event handler for click or key press.\n\nMore about pop-up blocker [from Mozilla developers][0].\n\n[0]: https://support.mozilla.org/en-US/kb/pop-blocker-settings-exceptions-troubleshooting" } [/block] If you need better visibility into the result of the operation, for example, to show custom error message, when opening a file fails, you can supply `onerror` and `onsuccess` to *openFileByUrl*: [block:parameters] { "data": { "h-0": "Callback", "h-1": "Description", "0-0": "onerror", "1-0": "onsuccess", "0-1": "Called when attempt to open a file failed for any reason.", "1-1": "Called after the file was opened successfully." }, "cols": 2, "rows": 2 } [/block] The application to open the file is determined using file name deduced from the URL. However, that would not work, if URL does not contain name of the file. In this case you can explicitly pass name of the file to *openFileByUrl* like this: [block:code] { "codes": [ { "code": "rollMyFile.openFileByUrl(\n {\"url\": \"http://www.example.com/file/12345678\",\n \"name\": \"overview.docx\"});", "language": "javascript" } ] } [/block]