ncssar / sartopo_python

Python calls for the caltopo / sartopo API -- SUPERCEDED by caltopo_python
GNU General Public License v3.0
16 stars 2 forks source link

What's the secret to uploading images? #85

Open petered opened 1 month ago

petered commented 1 month ago

Hey CalTopo-python-er(s),

Has anyone figured out the secret to uploading images?

From what I can tell, it's a 3-step dance.

1) POST request to https://caltopo.com/api/v1/media/<UUID_FOR_IMAGE> with a json payload {"properties":{"creator":"<USER_ID>","filename":"test_image.jpg","exifCreatedTZ":"America/Vancouver"}}

2) POST request to https://caltopo.com/api/v1/media/<UUID_FOR_IMAGE>/data with the json payload {"data":"/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBw0NDQ0.... <BIG LONG URL-SAFE BASE64-ENCODED IMAGE> ...}

3) POST request to https://caltopo.com/api/v1/map/<MAP_ID>/MapMediaObject containing the marker object, with reference to the image {"type":"Feature","id":null,"geometry":{"type":"Point","coordinates":[<LONGITUDE>,<LATITUDE>]},"properties":{"parentId":"","backendMediaId":"<UUID_FOR_IMAGE>","title":"test_image.jpg","heading":null,"description":"","marker-symbol":"aperture","marker-color":"#FFFFFF","marker-size":1}}

Step 1 works.. But I'm stuck at step 2 - getting a 500 server error in the response, and am at a bit of a loss as to why..

I'm working in Kotlin - otherwise I'd just post the code as a branch here.

Thanks all for any input! Will post the solution if I find it.

caver456 commented 1 month ago

Thanks for investigating, I haven't tried this. Good luck and looking forward to seeing a solution. If you find the magic formula then we can put it on the enhancement task list.

On Sat, Aug 10, 2024 at 2:46 PM petered @.***> wrote:

Hey CalTopo-python-er(s),

Has anyone figured out the secret to uploading images?

From what I can tell, it's a 3-step dance.

1.

POST request to https://caltopo.com/api/v1/media/ with a json payload {"properties":{"creator":"","filename":"test_image.jpg","exifCreatedTZ":"America/Vancouver"}}

2.

POST request to https://caltopo.com/api/v1/media//data with the json payload {"data":"/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBw0NDQ0.... ...} 3.

POST request to https://caltopo.com/api/v1/map//MapMediaObject containing the marker object, with reference to the image {"type":"Feature","id":null,"geometry":{"type":"Point","coordinates":[,]},"properties":{"parentId":"","backendMediaId":"","title":"test_image.jpg","heading":null,"description":"","marker-symbol":"aperture","marker-color":"#FFFFFF","marker-size":1}}

Step 1 works.. But I'm stuck at step 2 - getting a 500 server error in the response, and am at a bit of a loss as to why..

I'm working in Kotlin - otherwise I'd just post the code as a branch here.

Thanks all for any input! Will post the solution if I find it.

— Reply to this email directly, view it on GitHub https://github.com/ncssar/sartopo_python/issues/85, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEPCEZTYJIOEWIAFHNUTH6LZQ2C3VAVCNFSM6AAAAABMKEX5RSVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ2TSMRZHEZTGNI . You are receiving this because you are subscribed to this thread.Message ID: @.***>