From 66017b9d33116bf2563de3a95e342f9f8e7d2c86 Mon Sep 17 00:00:00 2001 From: Max Wofford Date: Tue, 6 Oct 2020 16:22:29 -0400 Subject: [PATCH] Attempt to fix duplicate filename error --- api/new.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/new.ts b/api/new.ts index d49023e..80d4aee 100644 --- a/api/new.ts +++ b/api/new.ts @@ -5,13 +5,13 @@ import { urlParse } from 'https://deno.land/x/url_parse/mod.ts'; // Vercel protects against env tokens starting with `VERCEL_`, so we're calling // it the ZEIT_TOKEN -const uploadFile = async (url: string) => { +const uploadFile = async (url: string, index: number) => { const req = await fetch(url) const data = new Uint8Array(await req.arrayBuffer()) const sha = new Hash('sha1').digest(data).hex() const size = data.byteLength const { pathname } = urlParse(url) - const filename = pathname.substr(pathname.lastIndexOf('/') + 1) + const filename = index + pathname.substr(pathname.lastIndexOf('/') + 1) const uploadedFile = await fetch('https://api.vercel.com/v2/now/files', { method: 'POST',