Giter Site home page Giter Site logo

screencloud-tokenupload's Introduction

URL Token Upload for ScreenCloud

ScreenCloud is an easy to use screenshot sharing tool consisting of a cross-platform client and a sharing website: http://screencloud.net/

The goal of this plugin is store (and process) your screanshots by a private endpoint.

Installation

Install URL Token Upload zip in ScreenCloud > Preferences > Online Services > More Services > Install from URL

Note: If you are using ScreenCloud version 1.2.0 or earlier, please use screencloud-tokenupload release v1.0.0 This version is written with Python 2, which is no longer compatible with ScreenCloud (since ScreenCloud 1.3.0).

Plugin Configuration

The plugin has a few simple configuration options

  • Token - Parameter used to authenticate with your endpoint
  • Address - URL address of your endpoint
  • Name - Name format for your screenshots

Endpoint Configuration

For your endpoint to interact properly with this plugin it requires the following functionality:

  • Accept Content-Type: application/json over POST request method
  • Return JSON formatted response
    • For success: {"href": "http://example.com/<screenshot>"}
    • For error: {"error": "<Error> happened"}

Installable Endpoint

For a ready-to-use endpoint written in Node.js, use Screencloud Token Upload Server.

Example Endpoint

Here is an example ednpoint implementation in PHP

<?php
/**
 * Simple file uplaod script.
 * NO WARRANTY. THIS SCRIPT IS ONLY AN EXAMPLE.
 * INPUT VALIDATION IS MINIMAL. DO NOT USE IN PRODUCTION
 *
 * @copyright 2014 Alex Soban
 * @license   http://opensource.org/licenses/MIT
 * @author    Alex Soban <[email protected]>
 */

define('TOKEN', '<secure_token>');
define('UPLOADS', __DIR__ . '/uploads/');
define('URL', 'http://www.example.com/uploads/');

function output(array $data = array()) {
    header('Content-Type: application/json');
    echo json_encode($data);
    exit;
}

// `name` check is optional
if (empty($_POST) || !isset($_POST['image']) || !isset($_POST['token']) || !isset($_POST['name'])) {
    output(array('error' => 'Invalid input.'));
}

// `token` verification
if ($_POST['token'] !== TOKEN) {
    output(array('error' => 'Invalid token.'));
}

// get the filename and contents
$filename = trim(preg_replace('/[^\d\w.]+/i', '', $_POST['name']));
$image = base64_decode($_POST['image']);

//  "upload" the file to our uploads directory
if (!file_put_contents(UPLOADS . $filename, $image)) {
    output(array('error' => 'Failed saving file.'));
}

// return file public URL
output(array('href' => URL . $filename));

screencloud-tokenupload's People

Contributors

sobanvuex avatar mattanderson97 avatar rezzedup avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.