Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to upload files to filestack using security policy and app secret #71

Open
prakash-p-3121 opened this issue Jan 9, 2023 · 1 comment

Comments

@prakash-p-3121
Copy link

Hi,
I'm using filestack to upload files.
Here's the code that I'm using

def main():


policy = {"call":["pick","store"],"expiry":1673461800}

p = Policy(policy,"APP_SECRET")
respSign = p.signature_params()

fpclient = FilepickerClientSecure('S3')
resp = fpclient.store_from_url("https://cdn.shopify.com/s/files/1/1390/1485/products/image_aacb3d0a-bed1-4265-99c5-5ec95dbf441b_1024x1024.jpg?v=1643292001",
                         respSign['policy'],
                         respSign['signature']
                        )


respStore = fpclient.store_local_file("/Users/user1/Desktop/user1.pdf",
                        respSign['policy'],
                        respSign['signature']
                        )
print(respStore)

The URL generated for the above calls are:

https://www.filestackapi.com/api/store/S3?policy=eyJjYWxsIjogWyJwaWNrIiwgInN0b3JlIl0sICJleHBpcnkiOiAxNjczNDYxODAwfQ%3D%3D&signature=fb265f83579e29ef11c047790a1b7a62755fa127d0b1f29d39ae8ab55ef395ae

When I pass the API_KEY in the URL query, I'm able to upload the files.

But if I use just the signature and policy I'm unable to upload the files. I get the following error.

response= Invalid Application status-code= 200

Can you please tell me how to fix this error ? Is it possible to upload files with policy and signature ?

@sethk4783
Copy link
Contributor

Hi @prakash-p-3121 please check example https://github.com/filestack/filestack-python/blob/develop/examples/upload_and_delete.py

@prakash-p-3121 as you correctly mentioned when passing API_KEY you're able to upload your files.

Similarly along with Security Policy and Signature you have to pass API_KEY.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants