public void EnsureFileNameStaysEqualWhileUploading( string canonical_name, string localPath, string remoteFolderPath, string url, string user, string password, string repositoryId, string binding) { ISession session = DotCMISSessionTests.CreateSession(user, password, url, repositoryId, binding); IFolder folder = (IFolder)session.GetObjectByPath(remoteFolderPath); string filename = "testfile.txt"; Dictionary <string, object> properties = new Dictionary <string, object>(); properties.Add(PropertyIds.Name, filename); properties.Add(PropertyIds.ObjectTypeId, BaseTypeId.CmisDocument.GetCmisValue()); try { IDocument doc = session.GetObjectByPath(remoteFolderPath.TrimEnd('/') + "/" + filename) as IDocument; if (doc != null) { doc.Delete(true); } } catch (CmisObjectNotFoundException) { } IDocument emptyDoc = folder.CreateDocument(properties, null, null); int length = 1024 * 1024; byte[] content = new byte[length]; ContentStream contentStream = new ContentStream(); contentStream.FileName = filename; contentStream.MimeType = MimeType.GetMIMEType(filename); contentStream.Length = content.Length; Action assert = delegate { Assert.That((session.GetObject(emptyDoc.Id, OperationContextFactory.CreateNonCachingPathIncludingContext(session)) as IDocument).Name, Is.EqualTo(filename)); }; using (var memstream = new AssertingStream(new MemoryStream(content), assert)) { contentStream.Stream = memstream; emptyDoc.SetContentStream(contentStream, true, true); } }
public void EnsureFileNameStaysEqualWhileUploading( string canonical_name, string localPath, string remoteFolderPath, string url, string user, string password, string repositoryId, string binding) { ISession session = DotCMISSessionTests.CreateSession(user, password, url, repositoryId, binding); IFolder folder = (IFolder)session.GetObjectByPath(remoteFolderPath); string filename = "testfile.txt"; Dictionary<string, object> properties = new Dictionary<string, object>(); properties.Add(PropertyIds.Name, filename); properties.Add(PropertyIds.ObjectTypeId, BaseTypeId.CmisDocument.GetCmisValue()); try { IDocument doc = session.GetObjectByPath(remoteFolderPath.TrimEnd('/') + "/" + filename) as IDocument; if (doc != null) { doc.Delete(true); } } catch (CmisObjectNotFoundException) { } IDocument emptyDoc = folder.CreateDocument(properties, null, null); int length = 1024 * 1024; byte[] content = new byte[length]; ContentStream contentStream = new ContentStream(); contentStream.FileName = filename; contentStream.MimeType = MimeType.GetMIMEType(filename); contentStream.Length = content.Length; Action assert = delegate { Assert.That((session.GetObject(emptyDoc.Id, OperationContextFactory.CreateNonCachingPathIncludingContext(session)) as IDocument).Name, Is.EqualTo(filename)); }; using (var memstream = new AssertingStream(new MemoryStream(content), assert)) { contentStream.Stream = memstream; emptyDoc.SetContentStream(contentStream, true, true); } }