ποΈDelete File
You can delete any uploaded file using the given function.
const deleteFile = async () => {
/*
@param {string} apiKey - Your API key.
@param {string} fileId - The unique file ID (UUID) of the file you want to delete.
Note: This is different from the file CID.
You can get fileId from lighthouse.getUploads()
or refer to the List Files section in docs.
*/
const response = await lighthouse.deleteFile(
"YOUR_API_KEY",
"b5f60ba0-b708-41a3-b0f2-5c808ce63b48"
);
console.log(response);
/* Sample response
{
"message": "File deleted successfully",
}
*/
};
deleteFile();
curl -X DELETE
-H "Authorization: Bearer API_KEY"
"https://api.lighthouse.storage/api/user/delete_file?id=FILE_ID"lighthouse-web3 delete-file <fileID>package main
import (
"context"
"fmt"
"log"
"os"
"github.com/lighthouse-web3/lighthouse-go-sdk/lighthouse"
)
func main() {
client := lighthouse.NewClient(nil,
lighthouse.WithAPIKey(os.Getenv("LIGHTHOUSE_API_KEY")),
)
ctx := context.Background()
// Delete a file by ID
fileID := "b5f60ba0-b708-41a3-b0f2-5c808ce63b48"
err := client.Files().Delete(ctx, fileID)
if err != nil {
log.Fatal(err)
}
fmt.Println("File deleted successfully")
}Note:
The
idparameter is required and should be the unique identifier of the file you want to delete.The file ID is different from the file CID. It is a UUID of the file. You can get it from
lighthouse.getUploads()or refer to the List Files section.Once deleted, the file cannot be recovered.
Last updated
Was this helpful?