FileStack client.upload()

I am trying to use the FileStack library in JavaScript and I figured out how to upload a file but can’t figure out how to make itself delete in a certain amount of time. (expiry)

const client = filestack.init('api key');

const input = document.createElement('input');
input.type = 'file';
input.onchange = e => {
    const file = e.target.files[0];
    console.log(file);
}
input.click();

client.upload(file);

Can anyone help please. Does anyone know how to make it delete the file after some time. (expiry)

Welcome to the community, @HexHands!
to delete… hmm… you’d need to have a timer. Will you keep the browser tab open? If not, it is possible for orphan uploads. I’d recommend getting a server to do the api stuff with the client handling the DOMs, with a setTimeout to delete the file. API usage should be documented in their api docs, but if not i could do some background reading.

1 Like

Well I won’t have the user keep the website open. I can setup a python github automation to delete stuff but I am not sure how to do the python side. I read the documentation and it said something about expiry. Does expiry not work for this?
Thanks for responding! Finally someone!

1 Like

I’ll have to read some docs, but in the meantime try looking for callbacks which listen for new files to keep track of, then have your server delete them x seconds after receiving the callback event.
[A FEW MOMENTS LATER…]

What do you think of just getting all files uploaded and then deleting ones that are more than a day old. That is what I need.

-Nvm I would need to store each url

  1. Transfer files through a backend server and then have the server auto delete it by keeping track of files
  2. [info required] Do the callback thing
  3. I couldn’t find in the docs for ephemeral file hosting :slightly_frowning_face:

Also I’ve found this: (the section)

does that answer something?


Also webhooks are in fact supported.

1 Like

That is what I have been looking at. That is where I found the expiry.

1 Like

Looking deeper, i guess that is for CDN caching to speed up CDN requests, not file storage. which backend do you use? Maybe attach something to your storage backend, IDK if it will affect filestack?

Well I have no backed except for serving the website. I am using the client.upload(file) to upload the file to filestack which returns the url for that file. When it returns the url it returns a CDN url.
Ex: https://cdn.filestackcontent.com/yANOJuUvTeip1jrJ1xwu

1 Like

Any progress? I haven’t gotten any. I did however find an alternative called Uploadcare.