1

I am trying to check-in a file into vault from my local, for that I need upload ticket, using this code in Powershell and getting a "155" exception. can anyone help me to solve this?

function Upload-FileResource {
    param (
        [Object] $vault,
        [string] $filename,
        [byte[]] $fileContents
    )
    
    $headerObject = New-Object Autodesk.Connectivity.WebServices.FileTransferHeader
    $headerObject.Identity = New-Guid
    $headerObject.Extension = [System.IO.Path]::GetExtension($filename)
    $headerObject.Vault = $vault.WebServiceCredentials.VaultName
    $uploadTicket = New-Object Autodesk.Connectivity.WebServices.ByteArray
    $bytesTotal = if ($null -ne $fileContents) { $fileContents.Length } else { 0 }
    $bytesTransferred = 0
    do {
        $bufferSize = $bytesTotal - $bytesTransferred
        if ($bufferSize -gt (49 * 1024 * 1024)) {
            $bufferSize = (49 * 1024 * 1024)
        }
 
        $buffer = $fileContents[$bytesTransferred..($bytesTransferred + $bufferSize - 1)]
        $headerObject.Compression = "None" 
        $headerObject.IsComplete = ($bytesTransferred + $bufferSize) -eq $bytesTotal
        $headerObject.UncompressedSize = $bufferSize
        $fileContentsStream = [System.IO.MemoryStream]::new($buffer)
        $uploadTicket.Bytes = $vault.FilestoreService.UploadFilePart($fileContentsStream)
        $bytesTransferred += $bufferSize
    } 
    while ($bytesTransferred -lt $bytesTotal)
    return $uploadTicket
}

$fileContents = [System.IO.File]::ReadAllBytes($localPath)
$uploadTicket = Upload-FileResource -vault $vault -filename $fileName -fileContents $fileContents
1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented May 24, 2024 at 17:37

1 Answer 1

0

I'm not using Powershell, but I had a look in the .Net documentation and found that error code 155 = "A null value was passed in where a null value is not allowed" . Seems you are passing null somewhere, hope that helps.

Screenshot Error codes

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.