linear / linear

Tools, SDK's and plugins for Linear

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

File upload process

jbarrella opened this issue · comments

What is the process for uploading files via the API? I would like to upload a small CSV file and attach it to an issue.

I have been using the fileUpload GraphQL mutation which returns a uploadUrl link. How do I send the csv data to this url? Currently, I am facing a "The request signature we calculated does not match the signature you provided" error message when trying to send the data to the uploadUrl using a PUT request.

Thanks.

Hi @jbarrella

I realize that our documentation lacks information about this process indeed.

In the payload you get back from fileUpload, there's also a headers object which contains some headers you should send along side the request to the uploadUrl. Example of return payload:

"uploadFile": {
                "filename": "... filename",
                "contentType": "image/png",
                "size": 156352,
                "uploadUrl": "... the upload URL",
                "assetUrl": ".... the asset URL",
                "metaData": null,
                "headers": [
                    {
                        "key": "x-goog-content-length-range",
                        "value": "156352,156352"
                    },
                    {
                        "key": "Content-Disposition",
                        "value": "attachment; filename=\"CleanShot 2023-07-26 at 12.10.52@2x.png\""
                    }
                ]
            }

Make sure to pass the two headers with your PUT request on uploadUrl. Let me know if this solves your issue.

Hi @guillaumelachaud

Thank you for the direction. Actually I find that, in my case, I do not require the Content-Disposition header, but I do require the x-goog-content-length-range and I also further require a content-type header which I have set to text/csv.

Either way, the issue is now resolved on my end. Thanks very much.

Sounds good!

Note that Content-Disposition is used to keep the original filename as a metadata. If you don't send it, the original filename will be lost and when downloading your file from Linear, it will be set to the obfuscated filename you received in uploadFile, which is basically a uuid.