0

I am generating a canvas on a document using JavaScript. I want to host the data URI of the canvas as an image file on a server.

Is there any hosting service or API which provides a way to temporarily host this file?

The purpose is to share the canvas in a Facebook feed, but the Facebook feed expects an image URL.

Eldelshell
  • 6,683
  • 7
  • 44
  • 63
  • 1
    no, you'll need to server the image data as a normal binary "file". you can upload the base64 to a server and have the server write a file, or you can conevert it to a "virtual file" in JS, look up "dataURL to Blob". Once you have the binary `Blob`, you can upload it like a normal file to a server using `FormData`. There is also a `canvas.toBlob()` method which saves some steps. – dandavis Jan 08 '17 at 13:17
  • is there any online service which provides hosting solution like this? – Saurabh Taneja Jan 08 '17 at 13:27
  • This is rather a question for google... – Jonas Wilms Jan 08 '17 at 13:48
  • or any way to achieve this in wordpress cms? – Saurabh Taneja Jan 08 '17 at 14:09

1 Answers1

0

there is no direct service as such to achieve this. You need to first create your image file on client side using Javascript and then with help of blob send a ajax call to upload image on your server. Please refer to this link for more info Upload base64 image with Ajax

Once done you can have a URL to this image which can be shared in facebook feed. If your server is Java based then you can refer to this link to understand how to create and remove temporary files from server http://alvinalexander.com/java/java-temporary-files-create-delete.

You can also refer to service like http://www.tiikoni.com/tis/ but I doubt they have APIs to store your temporary file.

Community
  • 1
  • 1
S4beR
  • 1,872
  • 1
  • 17
  • 33