已上传但未在服务器

时间:2017-07-25 03:26:14

标签: asp.net-web-api2 azure-web-sites

我使用此处所述的代码通过webapi http://bartwullems.blogspot.pe/2013/03/web-api-file-upload-set-filename.html上传文件。我还制作了以下API来列出我拥有的所有文件:

[HttpPost]
    [Route("sharepoint/imageBrowser/listFiles")]
    [SharePointContextFilter]
    public async Task<HttpResponseMessage>  Read()
    {
        string pathImages = HttpContext.Current.Server.MapPath("~/Content/images");

        DirectoryInfo d = new DirectoryInfo(pathImages);//Assuming Test is your Folder
        FileInfo[] Files = d.GetFiles(); //Getting Text files
        List<object> lst = new List<object>();
        foreach (FileInfo f in Files)
        {
            lst.Add(new
            {
                name = f.Name,
                type = "f",
                size = f.Length
            });
        }
        return Request.CreateResponse(HttpStatusCode.OK, lst);

    }

调用此api时,会列出上传的所有文件。但是当我去azure我没看到任何一个(Content.png是我手动上传到azure的文件) enter image description here

为什么列出的文件如果不出现在azure上。

1 个答案:

答案 0 :(得分:1)

根据您的描述,我建议您首先使用azure kudu控制台在azure Web门户中找到正确的文件夹以查看图像文件。

打开kudu控制台:

enter image description here

在kudu中单击调试控制台并找到site \ wwwroot \ yourfilefolder

enter image description here

如果您发现您的文件仍然无法成功上传,我猜您的上传代码可能有问题。我建议你可以试试下面的代码。

注意:您需要在wwwort文件夹中添加图像文件夹。

class func registerNotification() {
    if #available(iOS 10.0, *) {
        // push notifications
        UNUserNotificationCenter.current().requestAuthorization(options: [.sound, .alert, .badge]) {
            (granted, error) in
            if (granted) {
                UIApplication.shared.registerForRemoteNotifications()
            }
        }

        let center  = UNUserNotificationCenter.current()
        center.delegate = AppManager.appDel()
        center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in
            if error == nil {
                UIApplication.shared.registerForRemoteNotifications()
            }
        }
    } else {
        UIApplication.shared.registerUserNotificationSettings(UIUserNotificationSettings(types: [.badge, .sound, .alert], categories: nil))
        UIApplication.shared.registerForRemoteNotifications()
    }
}

结果:

enter image description here

相关问题