0

Background...

I'm exploring Parse.com as a back end for an iOS app that also has an html/web browser interface for some users (either via javascript client or asp.net client - to be determined). The web users are 'an audience' for the data/files the app users prepare in the app. They are not the same people.

I need to lock down access to objects in the database (no public access read or write) so I plan to set up an admin user belonging to an administrators role and create an app_users role applying class-level permissions to the various classes accordingly.

Then for my iOS app, using the anonymous users add them to the app_Users role, setting up a default ACL for object level permissions and interact with the data model accordingly.

The app creates PDF files and stores as PFFile objects and I want these to have no public read or write access too. these docs are what will be accessible via the web client.

So...

I don't think i want to use PFUsers for each potential user accessing via a web client -don't want it to over engineered. So I figured send params to Cloud Code (with useMasterKey()) to first return a list of file meta data to present to the user - this works well - I can return the PFFile url or objectId, doc name, file type and size...

The challenge...

Next I'd need to build a Cloud Code function which given objectId or a url will fetch the PDF file and return it in a way my web page can display it to the user.

I've seen a few examples in the Networking section of the docs looks like it might be possible but I can seem to join the dots.

Hope that makes sense - any thoughts?

Edit: Added Code

The code I've been looking at works for text/html - is it possible to response a PDF or binary

Parse.Cloud.httpRequest({ 
            url:'example.com/file.pdf', 
            success: function(httpResponse) { 
                        console.log(httpResponse.text);
            }, 
            error: function(httpResponse) {
                        console.error('Request failed: ' + httpResponse.status);
            });
Ox73
  • 1
  • 1
  • Please share what you have tried so far. It's easier for the readers to start with "something" than from scratch. – honk Sep 19 '14 at 16:52
  • I've looked at 'Parse.Cloud.httpRequest({ url:'http://www.example.com/file.pdf', success: function(httpResponse) { console.log(httpResponse.text); }, error: function(httpResponse) { console.error('Request failed: ' + httpResponse.status); }); }) but i've just been experimenting and not really sure if it's the write approach or what to do with the response – Ox73 Sep 19 '14 at 17:48
  • In my head i want to grab the PFFile using the PFFile url or presume can use an objectId – Ox73 Sep 19 '14 at 17:51
  • Please edit your question and include the code directly into your question. It's hard to read the code in the comment. – honk Sep 19 '14 at 18:18
  • ah sorry - how's that? – Ox73 Sep 19 '14 at 18:30

0 Answers0