-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add import and extractArchive methods #18
Conversation
PRO-4271 As an editor, I can import Apostrophe documents in my site
As an editor, I am able to import documents, related ones and related attachments to another site. These are contained in a ZIP file generated from a documents export in another site (or the current one). The ZIP file itself must be imported as it is to be sure everything is correctly imported and its content unchanged. When the import button from the import modal is triggered, the zip file must be sent to the server through a single POST request for this iteration (so will be limited in size). Read from ZIP fileThe backend will unzip the file using the same lib used to generate it, We would prefer using the node native lib. You might look a way to stream the content of the ZIP file to avoid having to load everything in memory before to read it. It should be ok now since we don't handle big loads of data, but in the future we will. AttachmentsIt must import attachments and documents from The you might need to make some modifications here to be able to write a file and to insert an existing attachment, you need at least, to keep the ID. If the attachment already exist (by ID) it must not be created, and the file not uploaded. We'll consider here that it has been imported in the past. DocumentsThen we need to import We will also need to keep track of duplicated documents IDs, to ask later to the user if we must override them. You must use the proper manager for each piece depending its type, and to use the the import process must be wrapped by the See this ticket for more information about the notification progress bar implementation. SingletonsIf the piece is from a module that has the option PagesFor this iteration we won't manage the download of all the exported page children. We still want to check the location of the page in the tree, if this one exists then we want to import the page at the same location (at least for the parent). If the path doesn't exists, simply put the page as a Home page child. PermissionsSince we will use the official insert/update Apostrophe methods, if they fail due to permissions the import should stop with an appropriate error. Acceptance Criteria
|
b0b9019
to
f5c2b2a
Compare
lib/methods/import.js
Outdated
|
||
let exportPath; | ||
try { | ||
exportPath = await format.input(file.path, file.name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exportPath = await format.input(file.path, file.name); | |
exportPath = await format.input(file.path); |
lib/methods/import.js
Outdated
@@ -0,0 +1,58 @@ | |||
const path = require('path'); | |||
const fsp = require('node:fs/promises'); | |||
const { EJSON } = require("bson"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { EJSON } = require("bson"); | |
const { EJSON } = require('bson'); |
d4adbbe
to
9fe9524
Compare
export
route toexport-batch
routeImporting docs and attachments is still to be done.