filestack / filestack-python

Official Python SDK for Filestack - API and content management system that makes it easy to add powerful file uploading and transformation capabilities to any web or mobile application.
https://www.filestack.com
Apache License 2.0
48 stars 20 forks source link

"Parameters are inalid" error #27

Closed italomaia closed 5 years ago

italomaia commented 6 years ago

Full error message: {"error":"Parameters are inalid","c":"8be69984-9626-48b9-88fe-201863fa4958","i":"UPL-us-e-1-22","t":1516679849}

I'm not sure what this error means, but it happens on upload.

staturecrane commented 6 years ago

@italomaia Can you provide me with some examples of the you are running that produces this error?

lukanus commented 6 years ago

@italomaia Hello I'm one of filestack's backend engineers. As for what we have for this request it seems we are not getting api key from you. Please, check this part of your configuration. Also, thank you for finding a typo in the error description. I'll correct that to proper "Parameters are invalid" as it suppose to be :)

italomaia commented 6 years ago

Hi @lukanus ; I'm using filestack with heroku and I'm instantiating the filestack client with the value of FILEPICKER_API_KEY, like this:

fs_client = FsClient(os.getenv('FILEPICKER_API_KEY'))
filelink = fs_client.upload(filepath=filepath)  # filepath is a file path string to a jpg file; error happens here

Am I missing something? @staturecrane

staturecrane commented 6 years ago

@italomaia Have you confirmed that the environment variable is getting passed properly? That's the only thing I can think of. Also, I presume the "FsClient" is just a renamed import of the Client from our module? Can you tell me which version of the Python SDK you are using?

italomaia commented 6 years ago

Full non-working example:

>>> from main import FsClient
>>> import os
>>> key = os.getenv('FILEPICKER_API_KEY')
>>> client = FsClient(key)
>>> with open("bla.txt", "w") as fs:
...     fs.write("bla bla")
... 
7
>>> len(key)
>>> 22
>>> client.upload("bla.txt")  # json.decoder.JSONDecodeError happens here
staturecrane commented 6 years ago

@italomaia Thanks for the info. The newest Filestack Python SDK does not have a FsClient class. Are you possibly using an older version or is that a wrapper class you are importing from main? Your client.upload is also not using the "filepath" keyword parameter, which is how the current SDK uploads local files (you had that in your previous examples, though).

If you can provide me with the version of the SDK you are using (by running pip show filestack-python), I can be of greater assistance.

italomaia commented 6 years ago

Actually, FsClient is declared like this, in main:

from filestack import Client as FsClient

Anyway, I'm using filestack-python==2.3.1

italomaia commented 6 years ago

To avoid further "mistyping", here is a full example done in a heroku python session:

>>> import os
>>> from filestack import Client as FsClient
>>> api_key = os.getenv("FILEPICKER_API_KEY")
>>> len(api_key)
22
>>> client = FsClient(api_key)
>>> with open("/tmp/hello", "w") as fs:
...     fs.write("hello world")
...
11
>>> with open("/tmp/hello") as fs:
...     print(fs.read())
...
hello world
>>> link = client.upload(filepath="/tmp/hello")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/app/.heroku/python/lib/python3.6/site-packages/filestack/models/filestack_client.py", line 131, in upload
    upload_processes=upload_processes, params=params, security=self.security
  File "/app/.heroku/python/lib/python3.6/site-packages/filestack/utils/upload_utils.py", line 138, in multipart_upload
    response_info = multipart_start(apikey, filename, filesize, mimetype, storage, params=params, security=security)
  File "/app/.heroku/python/lib/python3.6/site-packages/filestack/utils/upload_utils.py", line 45, in multipart_start
    raise Exception(response.text)
Exception: {"error":"Parameters are inalid","c":"b574fb0b-614f-4188-8f2c-64b34a507ffa","i":"UPL-us-e-1-21","t":1517029710}
>>> from subprocess import check_output
>>> data = check_output(["pip", "freeze"])
>>> print(data.decode())
certifi==2018.1.18
chardet==3.0.4
click==6.7
Empty==0.4.3
filestack-python==2.3.1
Flask==0.12.2
Flask-SQLAlchemy==2.3.2
Flask-WTF==0.14.2
future==0.16.0
gunicorn==19.7.1
idna==2.6
itsdangerous==0.24
Jinja2==2.10
MarkupSafe==1.0
psycopg2==2.7.3.2
requests==2.18.4
six==1.11.0
SQLAlchemy==1.2.1
trafaret==1.0.2
urllib3==1.22
Werkzeug==0.14.1
WTForms==2.1
bkwi commented 6 years ago

Hi @italomaia

I know it's been a while since your last comment but I wanted to let you know that the issue you reported should now be fixed (already in develop branch, not yet published on pypi)