Search code examples
filepicker.io

I imported old files into the S3 bucket - how can I access them with filepicker API?


I have old files prior filepicker what I now copied to the S3 bucket. Can I access them with the filepicker API to get them cropped?

I didn't find any relevant info in the documentation. According to the Stackoverflow threads, it seems I should store them again. Is it right?


Solution

  • To use filepicker.io conversion feature file has to be available via filepicker API.

    So first store amazon url: https://s3.amazonaws.com/your_own_bucket/ZynOv436QOirPYbJIr3Y_5qYoopVTsixCJJiqSWSE.png

    Using Filepicker REST API:

    curl -X POST -d url="https://s3.amazonaws.com/your_own_bucket/ZynOv436QOirPYbJIr3Y_5qYoopVTsixCJJiqSWSE.png" https://www.filepicker.io/api/store/S3?key=MY_API_KEY
    

    Sample response:

    {"container": "kg_bucket", "url": "https://www.filepicker.io/api/file/EmlSqNgR0CcgiKJQ70aV", "filename": "ZynOv436QOirPYbJIr3Y_5qYoopVTsixCJJiqSWSE.png", "key": "ILeMnXRB7ucPF1ILzQ9a_ZynOv436QOirPYbJIr3Y_5qYoopVTsixCJJiqSWSE.png", "type": "image/png", "size": 175210}
    

    Now you can convert filepicker url https://www.filepicker.io/api/file/EmlSqNgR0CcgiKJQ70aV

    Using GET request https://www.filepicker.io/api/file/EmlSqNgR0CcgiKJQ70aV/convert?w=200&h=250

    Or using POST request to store converted file

    curl -X POST "https://www.filepicker.io/api/file/EmlSqNgR0CcgiKJQ70aV/convert?format=jpg&quality=30&storeLocation=S3&storePath=/myFolder/myFile.png?key=MY_API_KEY"