doulan8152 2015-04-22 13:21
浏览 40
已采纳

Parse.com PHP SDK ParseFile图像403禁止

I'm using the Parse PHP SDK and trying to upload an image. The file successfully saves, however the URL for the file returned by the getUrl() ParseFile method returns a 403 forbidden when I try to view it. Viewing the file via the Parse data browser also returns a 403 error. I'm using Laravel, and have tried several different methods:

1) Upload the file to parse, save the object against the user and then access the File via the getURL() method:

$contents = Input::file('profile_picture');
$file = ParseFile::createFromData($contents, "profilePicture_".$contents->getClientOriginalName());
Auth::user()->set('profilePicture', $file);

// In My View
<img src="{{Auth::user()->get('profilePicture')->getUrl()}}"/>

The URL returned returns a 403 forbidden.

2) Upload the file to Parse and store the URL against the user

$contents = Input::file('profile_picture');
$file = ParseFile::createFromData($contents, "profilePicture_".$contents->getClientOriginalName());
Auth::user()->set('profilePicture', $file->getUrl());

// In My View
<img src="{{Auth::user()->get('profilePicture')}}"/>

I have also tried both the above using:

$file = ParseFile::createFromData($contents, "profilePicture".$contents->getClientOriginalExtension());

An example of the URL being returned looks like: http://files.parsetfss.com/2ed712aa-99d8-4df1-8100-a1f907042d43/tfss-37d8f8e3-b8fc-4980-8d45-4a24957a5dc0-profilePicturepong.jpg

  • 写回答

1条回答 默认 最新

  • dqteh7347 2015-04-23 00:02
    关注

    It was actually a case of me using the wrong method. I should have been using createFromFile

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?