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("filename", myFilename);
item_File_thumb.attachPhysicalFile(myFilepath);
Item item_File_thumb_result = item_File_thumb.apply();
...
My app is stuck at apply() so it's not return any error.
Then, I try another way:
...
Item item_File_thumb = inn.newItem("File", "add");
item_File_thumb.setProperty("filename", myFilename);
item_File_thumb.setProperty("actual_filename", myFilePath);
item_File_thumb.setProperty("checkedout_path", myDir);
Item located = item_File_thumb.createRelationship("Located", "add");
located.setProperty("related_id", "67BBB9204FE84A8981ED8313049BA06C"); // default vault
IomFactory factory = new IomFactory();
Aras.IOME.CheckinManager cm = factory.CreateCheckinManager(item_File_thumb);
Item result = cm.Checkin(1);
...
but it still not working. After Checkin(), everything is paused. because no return error so I do not know what's wrong.
Pls, help.
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