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

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 ansys fluent计算闪退
  • ¥15 有关wireshark抓包的问题
  • ¥15 Ubuntu20.04无法连接GitHub
  • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
  • ¥15 向数据表用newid方式插入GUID问题
  • ¥15 multisim电路设计
  • ¥20 用keil,写代码解决两个问题,用库函数
  • ¥50 ID中开关量采样信号通道、以及程序流程的设计
  • ¥15 U-Mamba/nnunetv2固定随机数种子
  • ¥30 C++行情软件的tick数据如何高效的合成K线