Writing your own uploader
If you're writing an app on top of Shade, this is how you upload files.
Multipart Uploads
Steps
1. Make sure you have a valid ShadeFS token. All calls will require this.
const resp = await axios.get(`https://api.shade.inc/workspaces/drives/${driveId}/shade-fs-token`, {
headers: {
Authorization: apiKey,
},
})const MUST_BE_LONGER_THAN_TO_BE_VALID = 240
const exp = jwtDecode(tokenJWT).exp
if (!exp) {
throw new Error("No exp attribute in decoded jwt")
}
if (exp - Date.now() / 1000 < MUST_BE_LONGER_THAN_TO_BE_VALID) {
// Token expires too soon, fetch another one
}2. Make sure that you've created the directories that you want to upload to. This call looks something like this:
3. Initiate the multipart upload to the destination path. This call looks something like this:
4. Now we can work on the parts. For each part, you will need to presign it first:
5. Now upload the part to the presigned URL. This call looks something like this:
6. Now just complete the upload
Example
Last updated

