{"id":385,"date":"2021-11-01T07:27:56","date_gmt":"2021-11-01T07:27:56","guid":{"rendered":"https:\/\/www.cartograph.eu\/v3\/?p=385"},"modified":"2022-04-05T14:49:48","modified_gmt":"2022-04-05T14:49:48","slug":"how-to-setup-a-custom-sync-server","status":"publish","type":"post","link":"https:\/\/www.cartograph.eu\/v3\/how-to-setup-a-custom-sync-server\/","title":{"rendered":"How to setup a custom sync server"},"content":{"rendered":"<div>\n\t\t\t\t<div class=\"addthis_toolbox addthis_default_style text-right\">\n\t\t\t\t<a class=\"addthis_button_facebook_like\" fb:like:layout=\"button_count\"><\/a>\n\t\t\t\t<a class=\"addthis_button_tweet\"><\/a>\n\t\t\t\t<a class=\"addthis_button_pinterest_pinit\" pi:pinit:layout=\"horizontal\"><\/a>\n\t\t\t\t<a class=\"addthis_counter addthis_pill_style\"><\/a>\n\t\t\t\t<\/div>\n\t\t\t\t<script async type=\"text\/javascript\">\n\t\t\t\tvar addthis_config = addthis_config||{};\n\t\t\t\taddthis_config.data_track_clickback = false;\n\t\t\t\taddthis_config.data_track_addressbar = false;\n\t\t\t\tvar addthis_share = {url: \"https:\/\/www.cartograph.eu\/v3\/how-to-setup-a-custom-sync-server\/\"};\n\t\t\t\t<\/script>\n\t\t\t\t<script async type=\"text\/javascript\" src=\"\/\/s7.addthis.com\/js\/300\/addthis_widget.js#pubid=ra-528087a8560a6838\"><\/script>\n\t\t\t\t<\/div>\n\n\n\n<p>The Cartograph app can sync data using a custom web server. The following tutorial describes how to setup a sync server.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p class=\"has-vivid-red-color has-text-color\"><strong>WARNING:<\/strong> This tutorial covers only the basic setup which is <strong>NOT secure<\/strong>. You have to employ custom measures, such as authentication (e.g. HTTPS, &#8220;.htaccess&#8221;, etc.), for securing the server.<\/p>\n\n\n\n<p>You can download an example PHP implementation <a href=\"https:\/\/www.cartograph.eu\/v3\/downloads\/misc\/syncserverexample.zip\">here<\/a>. The example <strong>MUST NOT <\/strong>be run on a public web server because it provides full file access.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Setup<\/h2>\n\n\n\n<p>Add a new &#8220;Custom webserver&#8221; to the cloud services. A popup dialog will show:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.cartograph.eu\/v3\/wp-content\/uploads\/2021\/11\/image-1024x842.png\" alt=\"\" class=\"wp-image-428\" width=\"512\" height=\"421\" srcset=\"https:\/\/www.cartograph.eu\/v3\/wp-content\/uploads\/2021\/11\/image-1024x842.png 1024w, https:\/\/www.cartograph.eu\/v3\/wp-content\/uploads\/2021\/11\/image-300x247.png 300w, https:\/\/www.cartograph.eu\/v3\/wp-content\/uploads\/2021\/11\/image-768x632.png 768w, https:\/\/www.cartograph.eu\/v3\/wp-content\/uploads\/2021\/11\/image-1536x1263.png 1536w, https:\/\/www.cartograph.eu\/v3\/wp-content\/uploads\/2021\/11\/image.png 1617w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/figure><\/div>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Name<\/strong>: An arbitrary name for identifying the server.<\/li><li><strong>Server address<\/strong>: The address of the sync server.<\/li><li><strong>Download url<\/strong>: The url where all files are located.<\/li><li><strong>Username\/Password<\/strong>: The username and password for accessing the web server (for instance defined in the .htaccess file).<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Server API<\/h2>\n\n\n\n<p>The custom sync server uses a simple query-based API for all operations. Commands are passed via the GET &#8220;cmd&#8221; argument:<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<h3 class=\"wp-block-heading\">getFileList<\/h3>\n\n\n\n<p>Gets a list of all files in a directory.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[GET] http:\/\/localhost:801\/cartograph3\/syncserver.php?token=sfndj23jsdfnksd28392&amp;cmd=getFileList&amp;subDir=ele_res<\/pre>\n\n\n\n<p>Parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>&#8220;<strong>subDir<\/strong>&#8220;: The directory to be queried.<\/li><\/ul>\n\n\n\n<p>Result:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n   \"error\":false,\n   \"file_list\":[\n      {\n         \"name\":\"p_aboriginal_lands.svg\",\n         \"size\":1048,\n         \"mod_time\":\"2021-11-03T07:12:45+00:00\",\n         \"is_dir\":false,\n         \"url\":\"http:\\\/\\\/localhost:801\\\/cartograph3.\\\/data\\\/ele_res\\\/p_aboriginal_lands.svg\"\n      },\n      {\n         \"name\":\"wm_frg_yellow_x.svg\",\n         \"size\":528,\n         \"mod_time\":\"2021-11-03T07:12:45+00:00\",\n         \"is_dir\":false,\n         \"url\":\"http:\\\/\\\/localhost:801\\\/cartograph3.\\\/data\\\/ele_res\\\/wm_frg_yellow_x.svg\"\n      }\n   ]\n}<\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<h3 class=\"wp-block-heading\">createDirectory<\/h3>\n\n\n\n<p>Creates a new directory.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[GET] http:\/\/localhost:801\/cartograph3\/syncserver.php?token=sfndj23jsdfnksd28392&amp;cmd=createDirectory&amp;subDir=ele_res&amp;newDir=test<\/pre>\n\n\n\n<p>Parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>&#8220;<strong>subDir<\/strong>&#8220;: The parent directory where the new directory will be created in.<\/li><li>&#8220;<strong>newDir<\/strong>&#8220;: The name of the new directory.<\/li><\/ul>\n\n\n\n<p>Result:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n   \"error\":false\n}<\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<h3 class=\"wp-block-heading\">deleteFile<\/h3>\n\n\n\n<p>Deletes a file or directory.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[GET] http:\/\/localhost:801\/cartograph3\/syncserver.php?token=sfndj23jsdfnksd28392&amp;cmd=deleteFile&amp;filePath=ele_res\/test<\/pre>\n\n\n\n<p>Parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>&#8220;<strong>filePath<\/strong>&#8220;: The file or directory which will be deleted.<\/li><\/ul>\n\n\n\n<p>Result:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n   \"error\":false\n}<\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<h3 class=\"wp-block-heading\">renameFile<\/h3>\n\n\n\n<p>Renames a file or directory.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[GET] http:\/\/localhost:801\/cartograph3\/syncserver.php?token=sfndj23jsdfnksd28392&amp;cmd=renameFile&amp;oldFilePath=ele_res\/test&amp;newFilePath=ele_res\/test2<\/pre>\n\n\n\n<p>Parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>&#8220;<strong>oldFilePath<\/strong>&#8220;: The file or directory to be renamed.<\/li><li>&#8220;<strong>newFilePath<\/strong>&#8220;: The new file or directory after renaming.<\/li><\/ul>\n\n\n\n<p>Result:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n   \"error\":false\n}<\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<h3 class=\"wp-block-heading\">uploadFile<\/h3>\n\n\n\n<p>Uploads a file to the server.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[POST] http:\/\/localhost:801\/cartograph3\/syncserver.php?token=sfndj23jsdfnksd28392&amp;cmd=uploadFile&amp;subDir=ele_res&amp;overwrite=true<\/pre>\n\n\n\n<p>Parameters:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>&#8220;<strong>subDir<\/strong>&#8220;: The directory where the file is saved to.<\/li><li>&#8220;<strong>overwrite<\/strong>&#8220;: If true then an eventually existing file shall be overwritten.<\/li><\/ul>\n\n\n\n<p>Result:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n   \"error\":false\n}<\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The Cartograph app can sync data using a custom web server. The following tutorial describes how to setup a sync<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-385","post","type-post","status-publish","format-standard","hentry","category-help"],"_links":{"self":[{"href":"https:\/\/www.cartograph.eu\/v3\/wp-json\/wp\/v2\/posts\/385","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cartograph.eu\/v3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cartograph.eu\/v3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cartograph.eu\/v3\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cartograph.eu\/v3\/wp-json\/wp\/v2\/comments?post=385"}],"version-history":[{"count":25,"href":"https:\/\/www.cartograph.eu\/v3\/wp-json\/wp\/v2\/posts\/385\/revisions"}],"predecessor-version":[{"id":1235,"href":"https:\/\/www.cartograph.eu\/v3\/wp-json\/wp\/v2\/posts\/385\/revisions\/1235"}],"wp:attachment":[{"href":"https:\/\/www.cartograph.eu\/v3\/wp-json\/wp\/v2\/media?parent=385"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cartograph.eu\/v3\/wp-json\/wp\/v2\/categories?post=385"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cartograph.eu\/v3\/wp-json\/wp\/v2\/tags?post=385"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}