Пример #1
0
        public static UploadFileInfo[] Upload(UserConfiguration userConfig, HTTP.FileContentData fileContentData)
        {
            var fileContentDatas = new HTTP.FileContentData[1];
            fileContentDatas[0] = fileContentData;

            return Upload(userConfig, fileContentDatas);
        }
Пример #2
0
        public static UploadFileInfo[] Upload(UserConfiguration userConfig, HTTP.FileContentData[] fileContentDatas)
        {
            if (userConfig != null)
            {
                Uri apiHost = ApiConfiguration.AuthenticationApiHost;

                string url = new Uri(apiHost, "files/upload/index.php").ToString();

                var postDatas = new NameValueCollection();
                postDatas["token"] = userConfig.SessionToken;
                postDatas["sender_id"] = UserManagement.SenderId.Get();

                var httpInfo = new HTTP.HTTPInfo();
                httpInfo.Url = url;
                httpInfo.ContentData = HTTP.PostContentData.FromNamedValueCollection(postDatas);
                httpInfo.FileData = fileContentDatas;

                string response = HTTP.POST(httpInfo);
                if (response != null)
                {
                    bool success = ApiError.ProcessResponse(response, "Upload File");
                    if (success)
                    {
                        var uploadFileInfos = JSON.ToType<List<UploadFileInfo>>(response);
                        if (uploadFileInfos != null)
                        {
                            return uploadFileInfos.ToArray();
                        }
                    }
                }
            }

            return null;
        }
Пример #3
0
        public static bool ProcessResponse(HTTP.ResponseInfo responseInfo, string label = null)
        {
            if (responseInfo != null && responseInfo.Body != null)
            {
                string s = Encoding.ASCII.GetString(responseInfo.Body);
                return ProcessResponse(s, label);
            }

            return false;
        }