diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb
index f88d866febc6f4d43769b521fbf03bdff4db4fec..a1f82ddd9c5835bc5cb89a67d67f98c20e9f0a2b 100644
--- a/app/controllers/projects/artifacts_controller.rb
+++ b/app/controllers/projects/artifacts_controller.rb
@@ -24,9 +24,14 @@ class Projects::ArtifactsController < Projects::ApplicationController
   end
 
   def file
-    # TODO, check if file exists in metadata
-    render json: { repository: build.artifacts_file.path,
-                   path: Base64.encode64(params[:path].to_s) }
+    file = build.artifacts_metadata_path(params[:path])
+
+    if file.exists?
+      render json: { repository: build.artifacts_file.path,
+                     path: Base64.encode64(file.path) }
+    else
+      render json: {}, status: 404
+    end
   end
 
   private