Drafts Action Directory

Save Post to DB & Share Link

Posted by @nahumck, Last update about 1 month ago - Unlisted

Save post to a markdown file with in the Post folder in Dropbox, then generate a share URL. Call the standard share sheet with the share URL passed as input.

Install

Steps

  • script

    // options
    let title = draft.processTemplate("[[safe_title]]")
    let ext = ".md"
    let path = "/Posts/" + title + ext;
    let content = draft.content;
    
    
    // write file to Dropbox
    let db = Dropbox.create();
    db.write(path, content, "overwrite", false);
    
    // generate share link and place it in clipboard
    let endpoint = "https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings";
    let args = {
    	"path": path,
    	"settings": {
    		"requested_visibility": "public"
    	}
    };
    let response = db.rpcRequest({
    	"url": endpoint,
    	"method": "POST",
    	"data": args
    });
    
    if (response.statusCode == 200) {
    	let shareURL = response.responseData["url"];
    	draft.setTemplateTag("url",shareURL);
    }
  • share

    template
    [[url]]

Options

  • After Success Default
    Notification Info
    Log Level Error
Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.