-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update: uploadthing to latest * checkpoint: form, api/post/create and dropzone ready. BD and PostView have to be adapted. * add: new column in Post with correct values * feat: all scripts adapted to urls Maybe it is time to do files instead of urls * refactor: urls (string[]) to files (File[])
- Loading branch information
Showing
17 changed files
with
391 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,3 @@ next-env.d.ts | |
|
||
userbase.csv | ||
pscale_dump_apunts-dades_main_20240310_112108 | ||
prisma/migrations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const { PrismaClient } = require("@prisma/client") | ||
const { default: axios } = require("axios") | ||
|
||
const prisma = new PrismaClient() | ||
|
||
async function updateRecords() { | ||
try { | ||
const recordsToUpdate = await prisma.Post.findMany() | ||
|
||
for (const record of recordsToUpdate) { | ||
const response = await axios.get(record.content, { | ||
responseType: "blob", | ||
}) | ||
const fileObject = new File([response.data], "PDF Sense Nom") | ||
|
||
await prisma.Post.update({ | ||
where: { id: record.id }, | ||
data: { | ||
files: JSON.stringify([ | ||
{ | ||
name: fileObject.name, | ||
size: fileObject.size, | ||
type: fileObject.type, | ||
url: record.content, | ||
}, | ||
]), | ||
}, | ||
}) | ||
} | ||
|
||
console.log("Records updated successfully.") | ||
} catch (error) { | ||
console.error("Error updating records:", error) | ||
} finally { | ||
await prisma.$disconnect() | ||
} | ||
} | ||
|
||
updateRecords() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
import { createNextRouteHandler } from "uploadthing/next" | ||
import { createRouteHandler } from "uploadthing/next" | ||
|
||
import { ourFileRouter } from "./core" | ||
|
||
// Export routes for Next App Router | ||
export const { GET, POST } = createNextRouteHandler({ | ||
export const { GET, POST } = createRouteHandler({ | ||
router: ourFileRouter, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.