简体   繁体   中英

Grab the individual files to be deleted based on that information

My problem right now is : When the customer uploads an image. then the old image must be deleted when uploading.

That is, the first one goes in and deletes the old file and then after uploading the new file that one has uploaded.

I have made a service that just has to handle this information around errors etc.

If I copy the url then I get the right content out of it.

Therefore, I expect that I can only delete the file I am referring to in the image. (Url)

图片在这里

public async Task RemoveFile(string courseId, string imgName)
    {
        BlobServiceClient blobServiceClient = new BlobServiceClient(AzureHelper.ConnectionString);
        var containerClient = blobServiceClient.GetBlobContainerClient(courseId);
        await containerClient.GetBlockBlobClient(imgName).DeleteIfExistsAsync();
    }

Please try to split imgName to get the real image name:

    var arr = imgName.Split("/");
    var name = arr[arr.Length-1];
    await containerClient.GetBlockBlobClient(name).DeleteIfExistsAsync();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM