edgestorejs / edgestore

https://edgestore.dev
397 stars 25 forks source link

Deleting files from s3 bucket - possible to use edgestore? #41

Closed aaa3334 closed 7 months ago

aaa3334 commented 7 months ago

Hi! I managed to get the delete method working on the backend with edgestore files, but couldnt seem to get it working with aws - wondering if that is my mistake in thinking it could work or if I am just doing something wrong here?

This is my backendClient and handler in the route.ts file

const handler = createEdgeStoreNextHandler({
  provider: AWSProvider(),
    logLevel: 'debug',
    router: edgeStoreRouter,
    createContext: createContext,
  });

export const backendClient = initEdgeStoreClient({
  router: edgeStoreRouter,
  baseUrl: 'http://localhost:3000/api/edgestore',
});

And this is how I am trying to access it on the backend:

export async function deleteVideoAws(urlToDelete: any) {
    const res = await backendClient.publicFiles.deleteFile({
      url: urlToDelete,
    });
    console.log(res)
  }

I can get this to work for those I have uploaded to the edgestore, but it doesnt work for those which I have uploaded to aws bucket - just wondering if this (simple and nice) method should work for aws or if I need to implement my own thing? Despite having 'debug' level on, all I get in return (res) is:

{ url: 'the s3 url I am trying to delete', success: false }

Thanks in advance!

perfectbase commented 7 months ago

Hi @aaa3334! Sorry for the late reply.. Yes, unfortunately the backend client is only for the Edge Store Provider. It could be possible to make it work for other providers, but it would have to be a big update. I added it to my list of possible future features.