private void btnCreate_Click(object sender, EventArgs e) { try { byte[] imageArray = null; try { imageArray = getImageByteArray(); } catch (Exception) { MessageBox.Show(Language.GetLocalizedText(-1, "Error with selected image")); return; } CloudCommunitiesUsersAPI.apiUsers uApi = new CloudCommunitiesUsersAPI.apiUsers(); string logoUrl = uApi.UploadFile(CloudCommunities.GetTokenFromId(), imageArray, txtImage.Text, "image/jpeg", false); apiCommunities api = new apiCommunities(); long newCommunityId = api.Create(CloudCommunities.GetTokenFromId(), txtName.Text, logoUrl, (OrderContentMethods)cmbOrder.SelectedItem, (PublicPermission)cmbAccess.SelectedItem, txtDescription.Text); createdCommunityId = newCommunityId; this.Close(); } catch (SoapException ex) { CloudCommunities.ProcessSoapException(ex); } }
public static string CallUploader(byte[] file, string name, string contentType, bool isImage) { apiUsers uploadApi = new apiUsers(); MD5CryptoServiceProvider md5Service = new MD5CryptoServiceProvider(); string md5 = BitConverter.ToString(md5Service.ComputeHash(file)).Replace("-", ""); string url = new apiUsers().getRealFileUrl(GetTokenFromId(), md5, contentType); if (!string.IsNullOrEmpty(url)) { return url; } return uploadApi.UploadFile(GetTokenFromId(), file, name, "image/jpeg", !isImage); }