vaphes / pocketbase

PocketBase client SDK for python
https://pypi.org/project/pocketbase/
MIT License
331 stars 38 forks source link

Support for protected files #72

Closed simon-lund closed 10 months ago

simon-lund commented 10 months ago

Hello again ^^

does the SDK support protected files yet? See here: https://pocketbase.io/docs/files-handling/#protected-files

I couldn't find the respective method in the SDK, but maybe I overlooked it?

m29h commented 10 months ago

Habe you tried doing the same thing like shown here on your protected file. My guess is that it works just out of the box. Every file in Pocketbase has always a sort of random id appended to the name. The only difference for protected files is that the random id will have a limited validity. This is enforced on the server side and should not need any explicit implementation on the client side.

(To refresh the ID you simply would call another get record query on the collection service and then pass the new result in the get_file_url method.

simon-lund commented 10 months ago

Hello, sorry I forgot to close this issues. I ended up imitating the getToken function from the js-sdk with the send(...) method provided by the python-sdk. Afaik I need this token, otherwise it creates a permanent link.

thangngoc89 commented 5 months ago

Just in case anyones came across this issue:

from pocketbase import Client

class PocketBase(Client):
    def get_file_token(self):
        return self.send("/api/files/token", req_config={"method": "POST"})