I have a set of File References in the database, some of which are local to the app (actual files), and some of which are remote (URLs).
Is there an easy way for me to test/check if the File References are actual files or not, without doing API calls to the filesystem? I was thinking checking if the reference contains the API URL, but that is not used. I can regex my way through that API URL and match on the App ID, but I have a feeling there is an easier way…
Hello @Egil_Helland,
The File Reference value returns URLs using the following logic:
- If the file is located outside of the current app, it will return the file URL as-is.
- If the file is within the current app, the returned file URL will include either the Domain or App ID/API Key used to make the request. For example:
Therefore, if you know how you made the request, you can check whether the returned file URL starts with your domain or not.
Thanks Stanislaw,
I ended up writing a simple regex, since I don’t necessarily know the domain, but verifying that the App ID is the same as for the API URL.
Screenshot for reference, if anyone needs to do something similar:
1 Like