简体   繁体   English

根据该信息获取要删除的单个文件

[英]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.如果我复制 url,那么我会从中得到正确的内容。

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:请尝试拆分imgName以获得真实的图像名称:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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