Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by Vitam · Jan 25, 2017 at 05:45 PM · webglscreenshotupload

How can I upload a WebGL game screenshot to Imgur?

I need a way to upload a screenshot to Imgur (or other img server) and get the url to it.

I was able to replicate in the editor what this user did: http://answers.unity3d.com/questions/1151550/how-can-i-upload-a-screenshot-directly-to-imgur.html#

But when I run it in my WebGL application, it crashes the browser while trying to upload the image. Can anyone shed a light on what is the problem here? An alternative way to do the same thing would help as well!

Edit:

I just realized that the code I tried didn't work because System.Net is not supported in WebGL. Is there a way to accomplish what I am trying to do, without it?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Vitam · Jan 25, 2017 at 11:51 PM

I was able to make it work with UnityWebRequest and WWWForm. Here is the code:

 IEnumerator UploadToImgur(byte[] rawImage) {
     string uploadedUrl = "";
     UnityWebRequest www;
             
     WWWForm wwwdata = new WWWForm();
     wwwdata.AddField("image", Convert.ToBase64String(rawImage));
     wwwdata.AddField("type", "base64");
     www = UnityWebRequest.Post("https://api.imgur.com/3/image.xml", wwwdata);
     
     string clientID = "YOUR IMGR CLIENT-ID HERE";
     www.SetRequestHeader("AUTHORIZATION", "Client-ID " + clientID);
             
     // if you want to display a loading image, here is where you should call it
     
     yield return www.Send();
     
     // disable loading image
     
     if (www.isError) {
         Debug.Log(www.error);
     }
     else {
         Debug.Log("Upload complete!");
         Debug.Log("Data: " + www.downloadHandler.text);
         XDocument xDoc = XDocument.Parse(www.downloadHandler.text);
         uploadedUrl = xDoc.Element("data").Element("link").Value;
     }
     Debug.Log(uploadedUrl); //This holds the url to the img
 }

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by UnitySeller · Feb 05, 2018 at 11:28 PM

Great code :) ..I found this also help and it is work too

https://answers.unity.com/questions/1151550/how-can-i-upload-a-screenshot-directly-to-imgur.html

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

93 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Upload images on server 0 Answers

Upload progress of file on unity WebGl 0 Answers

UI not working properly in webgl build (new input system) 0 Answers

Unity on MacOS build WebGL Error. 1 Answer

I use premade graphics that i found at google in one of my games... Can i upload my game on the web? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges