SHARE
TWEET

Untitled

a guest Jan 18th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. html2canvas(document.querySelector("#" + imageHtmlId)).then(function(canvas) {
  2.   var ranges = [...that.state.ranges];
  3.  
  4.   // insert the thumbnail at the top of the page
  5.  
  6.   document.body.appendChild(canvas);
  7.   document.body.removeChild(imageHtml);
  8.   ranges[0].pic = canvas.toDataURL("image/png", 0.1).replace("image/png", "image/octet-stream");
  9.  
  10.   that.setState({
  11.     ranges: ranges
  12.   });
  13.   return API.put("hands", `/hands/${that.props.match.params.handId}`, {
  14.     body: that.state.ranges
  15.   });
  16. })
  17.    
  18. createShareLink() {
  19.     try {
  20.      s3Upload(this.state.pic, this.state.id);
  21.     } catch (e) {
  22.       alert(e);
  23.       this.setState({ isLoading: false });
  24.     }
  25.   }
  26.    
  27. import { Storage } from "aws-amplify";
  28.  
  29. export async function s3Upload(file, filename) {
  30.    const stored = await Storage.put(filename, file, {
  31.     contentType: file.type
  32.    });
  33.  
  34.    return stored.key;
  35. }
  36.    
  37. var link = document.getElementById('link');
  38.   link.setAttribute('download', 'MintyPaper.png');
  39.   link.setAttribute('href',
  40. canvas.toDataURL("image/png").replace("image/png", "image/octet-stream"));
  41.   link.click();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top