Sahil Khanna
Sahil Khanna

Reputation: 4382

Displaying image in Parse.com Javascript throws 403 (forbidden)

I have uploaded images in Parse cloud. I'm using rest API to return the image URL to Javascript client (in Google Chrome). The image fails to load. When Inspected, the console in Chrome shows

GET http://files.parsetfss.com/bd4945df-f61a-4e6d-99cc-9a026fbadfa3/tfss-870a44af-fc02-4271-b365-aaeb6074cc10-dominos.png/ 403 (Forbidden).

But when I open the URL in browser, the image appears.

I tried returning the file object instead of the URL alone but I get the same issue with fileObject.url(). Below is the code for reference

In Javascript

Object contains a property named icon which has the URL of the parse file

<img src=' + returnedObject.icon + '/>

In Cloud Code

Temp is returned

var temp = {};
temp.prop1 = "something"
temp.icon = parseObject.get('icon').url();

Upvotes: 2

Views: 376

Answers (2)

Teddy
Teddy

Reputation: 1095

What if you replace this

<img src=' + returnedObject.icon + '/>

with this:

<img src="' + returnedObject.icon + '" />

?

Upvotes: 1

Ralphilius
Ralphilius

Reputation: 1856

The problem is with your URL. You have a trailing dash in the URL.

Upvotes: 1

Related Questions