title: How do I get a programmatically imported file to show in Files and image display?
body: <p>I have a custom object with a NoteID that I import along with two images related to it. I manually build the objects associated with uploading an image in code using an UploadFileMaintence graph. I can see the objects linked together in the database properly, and when I navigate to the custom detail page, the files show them as uploaded:
  <a href="https://i.stack.imgur.com/uglkr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uglkr.png" alt="enter image description here"></a></p>
  
  <p>However, when I click on the Files(2) button, when the dialog box comes up, I see nothing within the dialog:
  <a href="https://i.stack.imgur.com/qVL5Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qVL5Y.png" alt="enter image description here"></a></p>
  
  <p>Here are the four related tables (CustomTable, NoteDoc, UploadFile, and UploadFileRevision):</p>
  
  <p>CustomTable showing noteID and CheckURLName:
  <a href="https://i.stack.imgur.com/6rP5T.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6rP5T.png" alt="enter image description here"></a></p>
  
  <p>NoteDoc showing NoteID to FileID relationship:
  <a href="https://i.stack.imgur.com/LigKt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LigKt.png" alt="enter image description here"></a></p>
  
  <p>UploadFile:
  <a href="https://i.stack.imgur.com/bqeB2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bqeB2.png" alt="enter image description here"></a></p>
  
  <p>UploadFileRevision:
  <a href="https://i.stack.imgur.com/l8joO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l8joO.png" alt="enter image description here"></a></p>
  
  <p>Code to generate image upload entries:</p>
  
  <pre><code>    protected void AddDetailRow(List&lt;KeyValuePair&lt;int, string&gt;&gt; keypairs, InventoryItem givingType, string temp, UploadFileMaintenance graph)
      {
          //NOTE string temp contains the temporary directory address I created.
          CFBSContributionDetail detail = Details.Insert();
          //Code to populate detail object
          //NOTE: the variables front and back get populated with the file name of the image related to them.
          Details.Update(detail);
  
          this.Actions.PressSave();
  
          PX.SM.FileInfo frontInfo = new PX.SM.FileInfo(front, null, File.ReadAllBytes(temp + front));
          frontInfo.RevisionId = 1;
          frontInfo.Comment = front;
          frontInfo.UID = Guid.NewGuid();
          PX.SM.FileInfo backInfo = new PX.SM.FileInfo(back, null, File.ReadAllBytes(temp + back));
          backInfo.RevisionId = 1;
          backInfo.Comment = back;
          backInfo.UID = Guid.NewGuid();
          PXNoteAttribute.AttachFile(Details.Cache, detail, frontInfo);
          PXNoteAttribute.AttachFile(Details.Cache, detail, backInfo);
          Details.Update(detail);
          this.Actions.PressSave();
  
          UploadFile frontFile = new UploadFile();
          frontFile.FileID = frontInfo.UID;
          frontFile.Name = front;
          frontFile.Versioned = true;
          graph.Files.Insert(frontFile);
  
          UploadFileRevision frontImage = new UploadFileRevision();
          frontImage.FileID = frontInfo.UID;
          frontImage.Data = frontInfo.BinData;
          frontImage.FileRevisionID = 1;
          frontImage.BlobData = frontInfo.BinData;
          frontImage.Size = frontInfo.BinData.Length;
          graph.Revisions.Insert(frontImage);
  
          graph.Actions.PressSave();
  
          UploadFile backFile = new UploadFile();
          backFile.FileID = backInfo.UID;
          backFile.Name = back;
          backFile.Versioned = true;
          graph.Files.Insert(backFile);
  
          UploadFileRevision backImage = new UploadFileRevision();
          backImage.FileID = backInfo.UID;
          backImage.Data = frontInfo.BinData;
          backImage.FileRevisionID = 1;
          backImage.BlobData = backInfo.BinData;
          backImage.Size = backImage.BlobData.Length;
          graph.Revisions.Insert(backImage);
  
          graph.Actions.PressSave();
  
          detail.CheckImageUrl = front;
  
          Details.Update(detail);
  
          this.Actions.PressSave();
      }
  </code></pre>
  
  <p>One thing I noticed is that the image URLs stored in the UploadFile -> Name column are the screen type followed by a random set of numbers. I'm not sure how to generate that or if I even need to generate that. The files I'm uploading are of .TIF format, but I'm going to be changing them to .PNG since .TIF do not display within the browser.</p>
  
  <p>If there is a better way to perform this task, I'm open to completely changing what I've done so far.</p>
  
  <p>EDIT: I added code to transform the .tif files into .png files before uploading them.</p>