dstndstn / astrometry.net

Astrometry.net -- automatic recognition of astronomical images
http://astrometry.net
Other
661 stars 185 forks source link

How to upload a file by API? #248

Closed gabdeevmaksim closed 2 years ago

gabdeevmaksim commented 2 years ago

Good afternoon!

I have a problem to upload a file by API.

In documentation there is an example of data form for myfile.txt --===============2521702492343980833== Content-Type: text/plain MIME-Version: 1.0 Content-disposition: form-data; name="request-json"

{"publicly_visible": "y", "allow_modifications": "d", "session": "XXXXXX", "allow_commercial_use": "d"} --===============2521702492343980833== Content-Type: application/octet-stream MIME-Version: 1.0 Content-disposition: form-data; name="file"; filename="myfile.txt"

Hello World

--===============2521702492343980833==--

But if I need to upload fits file in which format I need to write content of the fits file into data form instead "Hello world"?

I've tried to convert the image to a string and encode it like in client.py example.

But I'm always getting "This file's type is not supported."

dstndstn commented 2 years ago

Don't encode it or anything; it's just the simple file contents like open(fn).read(). https://github.com/dstndstn/astrometry.net/blob/main/net/client/client.py#L177

If you want to tell me the submission ID, I can tell you what contents the server received.

gabdeevmaksim commented 2 years ago

Oh! Did't see that line. It'll be helpfull to write it in API documentation, for dummies like me. Thank you very mach for quick response!