public D2Document ImportD2DocumentWithContent(D2Document newObj, Stream otherPartStream, string otherPartMime, GenericOptions options)
        {
            Dictionary <Stream, string> otherParts = new Dictionary <Stream, string>();

            otherParts.Add(otherPartStream, otherPartMime);
            return(Client.Post <D2Document>(
                       this.Links,
                       LinkRelations.OBJECT_CREATION.Rel,
                       newObj,
                       otherParts,
                       options));
        }
        public D2Document ImportNewD2Document(FileInfo file, string documentName, string repositoryPath, D2Configuration d2config)
        {
            //if (!repositoryPath.StartsWith("/")) throw new Exception("Repository path " + repositoryPath + " is not valid."
            //     + " The path must be a fully qualified path");
            //Folder importFolder = getOrCreateFolderByPath(repositoryPath);
            //if (importFolder == null) throw new Exception("Unable to fetch or create folder by path: " + repositoryPath);

            D2Document newDocument = new D2Document();

            newDocument.SetPropertyValue("object_name", documentName);
            newDocument.SetPropertyValue("r_object_type", "dm_document");
            if (d2config != null)
            {
                newDocument.Configuration = d2config;
            }
            GenericOptions importOptions = new GenericOptions();

            importOptions.SetQuery("format", ObjectUtil.getDocumentumFormatForFile(file.Extension));
            D2Document created = ImportD2DocumentWithContent(newDocument, file.OpenRead(), ObjectUtil.getMimeTypeFromFileName(file.Name), importOptions);

            return(created);
        }