OK I surrender!
We have upgraded from Vault Pro 2013 to 2015 and now I cannot get our programs to add files into the vault.
We are using VB.net 2013 to add the files.
I have tried changing the DocumentService.AddFile to DocumentService.AddUploadedFile but I get a Error 8000 An unhandled exception of type 'System.Web.Services.Protocols.SoapException' occurred in Autodesk.Connectivity.WebServices.dll.
Here is the entire code for that...
Private Shared Function UploadFile(ByVal filePath As String, ByVal folderId As Long, ByVal serviceManager As WebServiceManager) As Long
'This function adds a file to the vault and returns the MasterID
Using stream As New System.IO.FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim fileData As ByteArray = New ByteArray()
fileData.Bytes = New Byte(stream.Length - 1) {}
stream.Read(fileData.Bytes, 0, fileData.Bytes.Length)
Dim oFile As Autodesk.Connectivity.WebServices.File
Try
oFile = serviceManager.DocumentService.AddUploadedFile(folderId, System.IO.Path.GetFileName(filePath), "Added by Vault ECN Creator", DateTime.Now, Nothing, Nothing, _
FileClassification.None, False, fileData)
UploadFile = oFile.MasterId
Catch ex As Exception
MsgBox(ex.Message)
UploadFile = -1
End Try
End Using
End Function
So I tried Wayne Brill's example of adding files using VDF. The problem here is that his example only allows for the folder to go 1 level deep. Our program has the user select a path in the vault so I have the folderID. Isn't there a way to set the folder directly using the folder ID or folder path without having to use a For Next to search the vault?
Web address to Wayne Brill's Example:
I really do not care what process I use to add files, so either way is fine.
Solved! Go to Solution.
Solved by smithmat. Go to Solution.
In 2015, the last parameter for DocumentService.AddUploadedFile is the uploadTicket (not the contents of the file). The upload ticket is obtained by first calling FilestoreService.UploadFilePart(fileContents).
Hope that helps,
- Matt
Thanks for the response Matt!
I have no idea how to get my file data into the correct format needed for the uploadticket argument. To be quite honest I don't even know what it is doing at this point in the code or why it needs that information.
You just replace this line:
oFile = serviceManager.DocumentService.AddUploadedFile(fol
with something similar to these two lines (not sure if my syntax is correct):
Dim uploadTicket As ByteArray = serviceManager.FilestoreService.UploadFilePart(fileData)
oFile = serviceManager.DocumentService.AddUploadedFile(fol
Hope that helps! Let me know how it goes,
- Matt
Thanks again Matt!
This line Dim uploadTicket As ByteArray = serviceManager.FilestoreService.UploadFilePart(fileData) is saying "Value of type 'Autodesk.Connectivity.WebServices.ByteArray' cannot be converted to 1-dimensional array of Byte.
This is what I have been trying to get around since you were kind enough to post the first time.
I hope you can help. Thanks!
Ah. I got some of the syntax wrong (sorry, I don't have this code up in a compiler right now). Try this modification:
Dim uploadTicket As ByteArray = New ByteArray()
uploadTicket.Bytes = serviceManager.FilestoreService.UploadFilePart(fileData)
oFile = serviceManager.DocumentService.AddUploadedFile(fol
- Matt
Note also that I think it might be necessary to set some of the FilestoreService's FileTransferHeaderValue properties before using UploadFilePart, and I'm assuming you haven't done this. Thus, while the code I gave you may help get you to compile, it may not work properly.
Thankfully, there is already a blog entry related to this with some sample code:
http://justonesandzeros.typepad.com/blog/2013/07/file-transfer-doing-it-the-hard-way.html
For ease of use, you could be using the SDK's method IFileManager.AddFile(...), but since you are porting old code (and you probably want to leave it as close to the same as it is as possible), you may just want to use the approach shown in the VB code from the blog post.
Good luck!
- Matt
Matt,
It is the fileData variable that is causing the problem. It is dimensioned like:
Dim fileData As ByteArray = New ByteArray(), and the UploadFilePart argument is asking for an array of Byte
I'm just not sure how to get the fileData into that format. Change the fileData to Dim fileData() As ByteArray = New Byte fails.
Oh, sorry, I missed that part. I think you just need to change the line to:
uploadTicket.Bytes = serviceManager.FilestoreService.UploadFilePart(fileData.Bytes)
I never could get the "old" way to work. No matter how I changed the filecontents it would not take the values. I even used the Doug Redmond's example you linked me to with no luck.
However, I did get Wayne Brill's example to work, but I still need to be able to set the folder lower than just the top level. Seems very odd that I would have to loop through all folders in my vault to find the folder I'm looking for. I know the exact pathway, because I have the user select it, so i have the FolderID. Isn't there a way to set the folder directly either using the ID or the pathway?
Below is the code that I have gotten to work, but of course it only works with the top level folders...
Dim results As VDF.Vault.Results.LogInResult = VDF.Vault.Library.ConnectionManager.LogIn(My.Settings.Server, My.Settings.DataBase, Vcred.UserName, My.Settings.Password, VDF.Vault.Currency.Connections.AuthenticationFlags.Standard, Nothing)
Dim connection As VDF.Vault.Currency.Connections.Connection = results.Connection
Dim myFldrCol As System.Collections.Generic.List(Of VDF.Vault.Currency.Entities.Folder)
myFldrCol = connection.FolderManager.GetChildFolders(connection.FolderManager.RootFolder, False, False)
' Get the folder to add the new file to change the FullName test to a Folder in your vault
Dim myFolder As VDF.Vault.Currency.Entities.Folder = Nothing
Dim FolderPath As String = serviceManager.DocumentService.GetFolderById(folderId).FullName
For Each Flder As VDF.Vault.Currency.Entities.Folder In myFldrCol
If Flder.FullName = FolderPath Then
'If Flder.FullName = filePath Then
myFolder = Flder
Exit For
End If
Next
If myFolder Is Nothing Then
MsgBox("Folder " & FolderPath & " not found in the vault", MsgBoxStyle.Critical, "File NOT Added!")
UploadFile = -1
Exit Function
End If
Dim myFileIterationNewFile As VDF.Vault.Currency.Entities.FileIteration = Nothing
Using fileStream As Stream = New FileStream(filePath, FileMode.Open, FileAccess.Read)
' Add the file to the vault
myFileIterationNewFile = connection.FileManager.AddFile(myFolder, Path.GetFileName(filePath), Path.GetFileName(filePath), DateTime.Now, Nothing, Nothing, FileClassification.None, False, fileStream)
End Using
'Logout
VDF.Vault.Library.ConnectionManager.LogOut(connection)
UploadFile = myFileIterationNewFile.EntityMasterId
Mike,
Yes, if you have the of the FolderID, you should be able to do it without getting all the folders and without looping through the folders.
The AddFile method takes an Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.Folder object that represents the intended parent folder. You can create one of these with a Connection (which you have as connection) and an Autodesk.Connectivity.WebServices.Folder (which you could have by saving off what you get back from the call to serviceManager.DocumentService.GetFolderById(folderId);
e.g.:
Dim folder As Autodesk.Connectivity.WebServices.Folder = serviceManager.DocumentService.GetFolderById(folderId)
Dim myFolder As VDF.Currency.Entities.Folder = New VDF.Currency.Entities.Folder(connection, folder)
Hope that helps,
- Matt
That did it!
Thanks Matt! I really appreciate all of your help and time!
What the working code looks like...
Dim results As VDF.Vault.Results.LogInResult = VDF.Vault.Library.ConnectionManager.LogIn(My.Settings.Server, My.Settings.DataBase, Vcred.UserName, My.Settings.Password, VDF.Vault.Currency.Connections.AuthenticationFlags.Standard, Nothing)
Dim connection As VDF.Vault.Currency.Connections.Connection = results.Connection
Dim lfolderID As Long = VaultfolderId
Dim folder As Autodesk.Connectivity.WebServices.Folder = serviceManager.DocumentService.GetFolderById(lfolderID)
Dim myFolder As VDF.Vault.Currency.Entities.Folder = New VDF.Vault.Currency.Entities.Folder(connection, folder)
Dim myFileIterationNewFile As VDF.Vault.Currency.Entities.FileIteration = Nothing
Using fileStream As Stream = New FileStream(filePath, FileMode.Open, FileAccess.Read)
' Add the file to the vault
myFileIterationNewFile = connection.FileManager.AddFile(myFolder, Path.GetFileName(filePath), Path.GetFileName(filePath), DateTime.Now, Nothing, Nothing, FileClassification.None, False, fileStream)
End Using
'Logout
VDF.Vault.Library.ConnectionManager.LogOut(connection)
UploadFile = myFileIterationNewFile.EntityMasterId
Can someone suggest,how to RENAME an assembly file in Autodesk Vault using VAULT API without breaking the relationship with its child and parent files?
Does Vault API has any RENAME filename FUNCTION or do we need to Checkout and provide new filename while CheckIn? It will be very helpful if you can provide some sample code.
Can't find what you're looking for? Ask the community or share your knowledge.