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

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

报告相同问题?

悬赏问题

  • ¥15 asp.textbox后台赋值前端不能显示什么原因
  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误