0

I'm working on an iOS and Android that app sends an email that contains 2 images. It doesn't attach the images to the email, rather it links to them via URL using the src property of the img tag in the email's HTML content. I would like to know if I can use Parse to store those images and reference the URLs for the ParseFiles in the email.

My questions are:

  • Do you just add the image to the database in a new class, or is there a separate location for public assets? (If not I can get the URL by clicking on the file which opens in a new tab in the browser.)
  • Is that URL guaranteed to never change so long as the image never changes? (If not I'd need to use a query to fetch the images from parse then get its url.)
  • Does visiting that URL for example in a web browser count as a request Parse keeps track for pricing purposes?

Piece of the email that will render the image:

<a href="" style="display: block; border-style: none !important; border: 0 !important;"><img width="186px" border="0" style="display: block; width: 186px;" src=\"http://url_to_photo_needs_to_go_here.png" alt=\"logo\"></a>
Jordan H
  • 52,571
  • 37
  • 201
  • 351
  • Can you add some tags for context? I'm assuming it might be app-development related. On Android? – sehe Jul 13 '15 at 22:54
  • @sehe It's mostly a web dev and Parse integration question, unless I have to query for the ParseFiles in the apps themselves – Jordan H Jul 13 '15 at 23:01

1 Answers1

0

You sure can. Every PFFile object includes a url property that you can use to directly access the file.

Simply grab this url property and insert it into the html for your email.

For reference: PFFile Class Reference for iOS (available for other SDK flavors too)

Ryan Kreager
  • 3,571
  • 1
  • 20
  • 35
  • What if you don't have a reference to the `PFFile` when the email is sent? Could I hardcode the URL I get back into the email and assume it will never change? – Jordan H Jul 14 '15 at 00:30
  • You could create a URL scheme whereby you convert a pre-defined url to match the PFFile later. However, it gets rather complicated. Can you save the PFFile before you send the email? – Ryan Kreager Jul 14 '15 at 00:33
  • The images are the exact same image for everyone. I would upload the images once and use them for a long time - potentially years. So yes I could manually upload the 2 images, get their URLs, copy and paste the URLs into the email, then remove the code that uploads the images. I am just uncertain if that would work or if the URL could possibly change. – Jordan H Jul 14 '15 at 01:16