{"id":850,"date":"2021-03-13T20:30:22","date_gmt":"2021-03-14T04:30:22","guid":{"rendered":"https:\/\/coderpad-staging.io\/?post_type=doc&#038;p=793"},"modified":"2025-02-21T04:19:52","modified_gmt":"2025-02-21T12:19:52","slug":"custom-files","status":"publish","type":"doc","link":"https:\/\/coderpad.io\/resources\/docs\/interview\/custom-files\/","title":{"rendered":"Custom files"},"content":{"rendered":"\n<p>Interview&#8217;s <em>Custom files<\/em> feature allows an interviewer to test a candidate\u2019s ability to manipulate data, navigate a file system programmatically, and prove their expertise in a system very similar to what they\u2019ll encounter on the job.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\">\n<p>\u26a0\ufe0fNote that this custom files feature is currently not available for use with multi-file frameworks like React or Angular. For these environments <a href=\"https:\/\/coderpad.io\/resources\/docs\/interview\/question-bank\/creating-a-question\/\">you can add the file directly to the file directory when you create the question<\/a>.<\/p>\n\n\n\n<p>Similarly, for Jupyter Notebooks, proceed to <em>Step 3<\/em> of the question wizard and then just drag your files from your desktop directly into the notebook. Once you save the question they&#8217;ll be stored with it and always load when you load the question.<\/p>\n<\/blockquote>\n\n\n\n<p><\/p>\n\n\n\n<p>After you have uploaded the files, you can attach them to questions. Typical use-cases for custom files are importing data from CSVs files for analysis, or analyzing log files in text format to aid in debugging exercises.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\">\n<p>\u2757 Image file types (<code>.jpg<\/code>, <code>.png<\/code>, <code>.pdf<\/code>, etc.) will not render as images in the pad. The file bytecode will be displayed instead. <\/p>\n\n\n\n<p>If you wish to show images to a candidate, <a href=\"https:\/\/coderpad.io\/resources\/docs\/interview\/question-bank\/creating-a-question\/#question-metadata\">include it in the candidate instructions<\/a> using Markdown instead.<\/p>\n<\/blockquote>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#create-file\">Create a custom file<\/a><\/li>\n\n\n\n<li><a href=\"#attach-file\">Attach a custom file to a question<\/a><\/li>\n\n\n\n<li><a href=\"#access-file\">Accessing the file from a pad<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"create-file\">Create custom file<\/h2>\n\n\n\n<p>To add a custom file for use in an interview question, first click <strong>Files <\/strong>in the left-side navigation bar of your dashboard.&nbsp;<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/d2h1bfu6zrdxog.cloudfront.net\/wp-content\/uploads\/2023\/03\/image-60.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"288\" src=\"https:\/\/d2h1bfu6zrdxog.cloudfront.net\/wp-content\/uploads\/2023\/03\/image-60-1024x288.png\" alt=\"The files menu item is highlighted in the left nav, and the page is shown in the center of the window.\" class=\"wp-image-32382\" srcset=\"https:\/\/coderpad.io\/wp-content\/uploads\/2023\/03\/image-60-1024x288.png 1024w, https:\/\/coderpad.io\/wp-content\/uploads\/2023\/03\/image-60-300x84.png 300w, https:\/\/coderpad.io\/wp-content\/uploads\/2023\/03\/image-60-768x216.png 768w, https:\/\/coderpad.io\/wp-content\/uploads\/2023\/03\/image-60-1536x431.png 1536w, https:\/\/coderpad.io\/wp-content\/uploads\/2023\/03\/image-60-18x5.png 18w, https:\/\/coderpad.io\/wp-content\/uploads\/2023\/03\/image-60.png 1595w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>Then click <strong>Create File<\/strong> to upload your file. Make sure to give your file a descriptive and recognizable name that you can refer to in the question.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/d2h1bfu6zrdxog.cloudfront.net\/wp-content\/uploads\/2023\/03\/image-61.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"288\" src=\"https:\/\/d2h1bfu6zrdxog.cloudfront.net\/wp-content\/uploads\/2023\/03\/image-61-1024x288.png\" alt=\"On the custom files page the &quot;create file&quot; button is highlighted in the top right of the screen.\" class=\"wp-image-32383\" srcset=\"https:\/\/coderpad.io\/wp-content\/uploads\/2023\/03\/image-61-1024x288.png 1024w, https:\/\/coderpad.io\/wp-content\/uploads\/2023\/03\/image-61-300x84.png 300w, https:\/\/coderpad.io\/wp-content\/uploads\/2023\/03\/image-61-768x216.png 768w, https:\/\/coderpad.io\/wp-content\/uploads\/2023\/03\/image-61-1536x431.png 1536w, https:\/\/coderpad.io\/wp-content\/uploads\/2023\/03\/image-61-18x5.png 18w, https:\/\/coderpad.io\/wp-content\/uploads\/2023\/03\/image-61.png 1595w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>You&#8217;ll then see a pop-up to upload your file. Drop it into the box, give it a title, and then click <strong>Upload File<\/strong> to add it to your file library.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/d2h1bfu6zrdxog.cloudfront.net\/wp-content\/uploads\/2023\/05\/image-6.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"591\" height=\"641\" src=\"https:\/\/d2h1bfu6zrdxog.cloudfront.net\/wp-content\/uploads\/2023\/05\/image-6.png\" alt=\"File upload popup. There is a place to drag and drop  the file, add a tile, and add a description.\" class=\"wp-image-33767\" srcset=\"https:\/\/coderpad.io\/wp-content\/uploads\/2023\/05\/image-6.png 591w, https:\/\/coderpad.io\/wp-content\/uploads\/2023\/05\/image-6-277x300.png 277w, https:\/\/coderpad.io\/wp-content\/uploads\/2023\/05\/image-6-11x12.png 11w\" sizes=\"auto, (max-width: 591px) 100vw, 591px\" \/><\/a><\/figure>\n<\/div>\n\n\n<blockquote class=\"wp-block-quote\">\n<p>\u26a0\ufe0fYour file title should only contain letters, numbers, hypens, and\/or underscores. Using other symbols may interfere with code execution in the pad. <\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"attach-file\">Attach a custom file to a question<\/h2>\n\n\n\n<p>Custom Files must be associated with a question in your Question Library. Attach a custom file to a question in <em>Step 2 &#8211; Add Code Elements<\/em> of the question wizard. You can attach up to three files per question.<\/p>\n\n\n\n<figure class=\"wp-block-video aligncenter\"><video height=\"896\" style=\"aspect-ratio: 1906 \/ 896;\" width=\"1906\" autoplay controls loop muted src=\"https:\/\/d2h1bfu6zrdxog.cloudfront.net\/wp-content\/uploads\/2023\/03\/customfilesvid.mp4\"><\/video><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"access-file\">Accessing a file in an interview<\/h2>\n\n\n\n<p>During the interview, once a question with an attached file has been loaded, the candidate can access the file from the <code>.\/data\/<\/code> directory. Here are some examples:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Python<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python shcb-wrap-lines\">f = open(<span class=\"hljs-string\">'.\/data\/addresses.csv'<\/span>, <span class=\"hljs-string\">'r'<\/span>)\nprint(<span class=\"hljs-string\">'Filename:'<\/span>, f.name)\nprint(f.read())<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">JavaScript<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">const<\/span> fs = <span class=\"hljs-built_in\">require<\/span>(<span class=\"hljs-string\">\"fs\"<\/span>);\n<span class=\"hljs-keyword\">const<\/span> csv = fs.readFileSync(<span class=\"hljs-string\">\".\/data\/test.csv\"<\/span>)\n<span class=\"hljs-built_in\">console<\/span>.log(csv.toString());<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Java<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"Java\" data-shcb-language-slug=\"java\"><span><code class=\"hljs language-java shcb-wrap-lines\">File file = <span class=\"hljs-keyword\">new<\/span> File(<span class=\"hljs-string\">\".\/data\/test.csv\"<\/span>);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Java<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">java<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Ruby<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"Ruby\" data-shcb-language-slug=\"ruby\"><span><code class=\"hljs language-ruby shcb-wrap-lines\">puts File.open(<span class=\"hljs-string\">'.\/data\/test.csv'<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Ruby<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">ruby<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<blockquote class=\"wp-block-quote\">\n<p>\u260e\ufe0f <a href=\"\/contact\/support\/\" target=\"_blank\" rel=\"noreferrer noopener\">Contact support<\/a> if you have any problems accessing the files.<\/p>\n<\/blockquote>\n","protected":false},"parent":16734,"menu_order":7,"template":"","class_list":["post-850","doc","type-doc","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/doc\/850","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/doc"}],"about":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/types\/doc"}],"version-history":[{"count":36,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/doc\/850\/revisions"}],"predecessor-version":[{"id":42148,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/doc\/850\/revisions\/42148"}],"up":[{"embeddable":true,"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/doc\/16734"}],"wp:attachment":[{"href":"https:\/\/coderpad.io\/wp-json\/wp\/v2\/media?parent=850"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}