Forum Discussion

DucTran's avatar
DucTran
Ideator I
6 years ago
Solved

upload a simple file to vault

Hi everyone, I try to make an app with aras.iom by C#. I want to upload a file to vault with code: ... Item item_File_thumb = this.inn.newItem("File", "add"); item_File_thumb.setProperty("fil...
  • christopher_gillis's avatar
    6 years ago

    Hello,

    As Angela has said, I'm not seeing anything wrong with your code itself. I tried running the same code in an IOM app on my local machine, and I was able to upload the file successfully. For reference, the exact code I used can be seen below:

    // Login variables defined above and intentionally left out of sample
    HttpServerConnection conn = IomFactory.CreateHttpServerConnection(url, database, username, password);
    Item res = conn.Login();
    // Make sure we logged in correctly
    if (res.isError())
    {
        Console.WriteLine("Could not log in");
        return;
    }
    // Upload the file
    Innovator inn = new Innovator(conn);
    Item file_upload = inn.newItem("File", "add");
    file_upload.setProperty("filename", "test.txt");
    file_upload.attachPhysicalFile(@"C:\Temp\test.txt");
    file_upload.apply();
    // Check that the file uploaded successfully
    if (file_upload.isError())
    {
        Console.WriteLine("Could not upload file");
    }
    // Let us know if the file uploaded successfully
    Console.WriteLine("File uploaded");

    This leads me to believe that the issue is not with your code itself. I think the issue might be that the computer permissions on the physical file itself might be preventing this upload. Could you try to check those permissions (in the Windows explorer, Right-click -> Properties -> Security)? Could you also try to upload the same file as the same user through the Innovator client?

    Chris