CN114500518A - File uploading and downloading method and device, computer equipment and storage medium - Google Patents

File uploading and downloading method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN114500518A
CN114500518A CN202210331359.1A CN202210331359A CN114500518A CN 114500518 A CN114500518 A CN 114500518A CN 202210331359 A CN202210331359 A CN 202210331359A CN 114500518 A CN114500518 A CN 114500518A
Authority
CN
China
Prior art keywords
downloading
file
uploading
electron
desktop application
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210331359.1A
Other languages
Chinese (zh)
Inventor
邓垚
史伟
黄衍博
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Eflycloud Computing Co Ltd
Original Assignee
Guangdong Eflycloud Computing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Eflycloud Computing Co Ltd filed Critical Guangdong Eflycloud Computing Co Ltd
Priority to CN202210331359.1A priority Critical patent/CN114500518A/en
Publication of CN114500518A publication Critical patent/CN114500518A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5061Partitioning or combining of resources

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The application belongs to the field of file transmission, and relates to a file uploading and downloading method, a file uploading and downloading device, computer equipment and a storage medium, wherein the method comprises the following steps: the desktop application framework Electron starts go through spawn of the node, and the go generates an executable program exe; selecting a file by an Electron for uploading and downloading, storing information of the uploaded and downloaded file by vuex, and storing the information of the uploaded and downloaded file into a database sqlite 3; the executable program exe establishes connection with an Electron through a socket; and the Electron sends the tasks of file uploading and downloading and the user interface display to go, and go executes the program. Through the division and cooperation of the Electron, the go and the sqlite3, the file uploading and downloading speed is high, the process consumption is low, and the file transmission efficiency is improved.

Description

File uploading and downloading method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of file transmission technologies, and in particular, to a method and an apparatus for uploading and downloading a file, a computer device, and a storage medium.
Background
Electronic is a framework for building desktop applications by using JavaScript, HTML and CSS, and is commonly used in software development on a PC side, such as a web disk, communication software, and the like, which all require file uploading and downloading operations. Considering that the javaScript is a single-thread factor and is limited in concurrent uploading and downloading, go is used as an operation uploading and downloading end, block uploading and downloading are performed, breakpoint uploading and downloading can be performed, and the Electron is used as ui display. The method comprises the steps of carrying out a will-download downloading function of an Electron, uploading a form, and uploading blocks and downloading realized by js, wherein the will-download can support breakpoint download, but the downloading needs to be carried out again after a program is closed, a large file is uploaded by the form to block a page, and the uploading of the js blocks is single-threaded. And uploading and downloading the multi-process file of the Electron, starting a js process by using the child _ process of the node for uploading and downloading tasks, and managing the child _ processes generated by the node by the Main Process of the Electron, but the process overhead is large.
Disclosure of Invention
An object of the embodiment of the present application is to provide a file uploading and downloading method, device, computer device, and storage medium, so as to solve the problem in the prior art that single-thread uploading efficiency is low or overhead of a multi-process file uploading and downloading process is large in file uploading and downloading based on Electron.
In order to solve the above technical problem, the present application provides a file uploading and downloading method, which adopts the following technical scheme, including the following steps:
the desktop application framework Electron starts go through spawn of the node, and the go generates an executable program exe;
selecting a file by a desktop application framework Electron for uploading and downloading, storing information of the uploaded and downloaded file by vuex, and storing the information of the uploaded and downloaded file into a database sqlite 3;
the executable program exe establishes connection with an Electron through a socket;
and the desktop application framework Electron sends the tasks of file uploading and downloading and the user interface display to go, and go executes the program.
Further, the uploading and downloading file information includes:
the file uploading and downloading progress, the uploading and downloading state, the uploading and downloading speed, the file size, the file name, the uploading and downloading completion time, the downloading path, the uploading path, the file ID number and the MD5 value of the file.
Further, the database sqlite3 displays tasks in a paging mode, and 100-200 tasks are set to be one page.
Furthermore, the number of go execution programs is set to be 5-20.
Further, the desktop application framework Electron starts go through spawn of the node, and the step of generating the executable program exe by the go further comprises:
establishing socket connection between the executable program exe and a desktop application framework Electron, taking the executable program exe as a service end of the socket, and taking the desktop application framework Electron as a client end of the socket;
and starting the file uploading and downloading task executable program on the desktop application framework Electron.
Further, the step of establishing connection between the executable program exe and the desktop application framework Electron through the socket further includes:
acquiring available ports 9000-65539 by a desktop application framework Electron;
the desktop application framework Electron starts an executable program exe through spwan and transmits the executable program exe into available ports 9000-65539 and a sqlite3 database path;
after the executable program exe is started, a socket server is established according to available ports 9000-65539;
the desktop application framework Electron establishes a socket client according to the available ports 9000-65539, and communicates with the executable program exe.
Further, the desktop application framework Electron sends a task of file uploading and downloading and a user interface display to go, and the step of go executing the program further comprises:
the desktop application framework Electron sends a task of file uploading and a user interface display to go, the go executive program and the desktop application framework Electron send a task of file downloading and a user interface display to go, and go executive program. In order to solve the above technical problem, the present application further provides a file uploading and downloading device, which adopts the following technical scheme, including:
the starting module is used for enabling the desktop application framework Electron to start a go through spawn of the node, and generating an executable program exe from the go;
the configuration module is used for selecting files for uploading and downloading by the desktop application framework Electron, storing information of the uploaded and downloaded files by vuex, and storing the information of the uploaded and downloaded files into a database sqlite 3;
the connection module is used for establishing connection between the executable program exe and the desktop application frame Electron through a socket;
and the execution module is used for sending the tasks of file uploading and downloading and the user interface display to go by the desktop application framework Electron, and the go executes the program.
In order to solve the above technical problem, the present application further provides a computer device, which adopts the following technical scheme: the file uploading and downloading method comprises a memory and a processor, wherein computer readable instructions are stored in the memory, and the steps of the file uploading and downloading method are realized when the processor executes the computer readable instructions.
In order to solve the above technical problem, the present application further provides a computer-readable storage medium, which adopts the following technical solutions: the computer readable storage medium stores computer readable instructions, and the computer readable instructions, when executed by the processor, implement the steps of the file uploading and downloading method.
Compared with the prior art, the application mainly has the following beneficial effects: on the basis of the existing Electron, go is used for generating an executable program exe, the executable program exe is in communication connection with the Electron through socket, the Electron is responsible for sending an uploading and downloading task and ui display, go is responsible for executing the program, and sqlite stores downloading records, so that the file uploading and downloading speed is high, the process consumption is low, the file transmission efficiency is improved through division and cooperation of the Electron, go and sqlite3, and the method can be widely applied to the technical field of file uploading and downloading frequency.
Drawings
In order to more clearly illustrate the solution of the present application, the drawings needed for describing the embodiments of the present application will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present application, and that other drawings can be obtained by those skilled in the art without inventive effort.
FIG. 1 is an exemplary system architecture diagram in which the present application may be applied;
FIG. 2 is a flowchart of one embodiment of a file upload and download method of the present application;
FIG. 3 is a flowchart illustrating the initiation of a file upload and download process in the present application;
FIG. 4 is a flowchart of the present application for performing file upload and download;
FIG. 5 is a flowchart illustrating the initialization of a file upload and download task according to the present application;
FIG. 6 is a flowchart of suspending file upload and download tasks in the present application;
FIG. 7 is a flowchart of the task of resuming file upload and download in the present application;
FIG. 8 is a schematic structural diagram of an embodiment of a file uploading and downloading device of the present application;
fig. 9 is a schematic structural diagram of another embodiment of a file uploading and downloading device of the present application;
FIG. 10 is a schematic block diagram of one embodiment of a computer device of the present application.
Detailed Description
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "including" and "having," and any variations thereof, in the description and claims of this application and the description of the above figures are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the description and claims of this application or in the above-described drawings are used for distinguishing between different objects and not for describing a particular order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
As shown in fig. 1, the system architecture 100 may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium of communication links between the first terminal device 101, the second terminal device 102, the third terminal device 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the first terminal device 101, the second terminal device 102, the third terminal device 103 to interact with the server 105 via the network 104 to receive or send messages or the like. Various communication client applications, such as a web browser application, a shopping application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like, may be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103.
The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, E-book readers, MP3 players (Moving Picture E file uploading/downloading parts Group Audio Layer III, mpeg compression standard Audio Layer 3), MP4 players (Moving Picture E file uploading/downloading parts Group Audio Layer IV, mpeg compression standard Audio Layer 4), laptop portable computers, desktop computers, and the like.
The server 105 may be a server that provides various services, such as a background server that provides support for pages displayed on the first terminal apparatus 101, the second terminal apparatus 102, and the third terminal apparatus 103.
It should be noted that, the file uploading and downloading method provided by the embodiment of the present application is generally executed by a server/terminal device, and accordingly, the file uploading and downloading apparatus is generally disposed in the server/terminal device.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Example one
With continuing reference to FIG. 2, a flowchart of one embodiment of a file upload and download method according to the present application is shown. The file uploading and downloading method comprises the following steps:
in step S201, the desktop application framework Electron starts go through spawn of the node, and generates the executable program exe from go.
The go executive program refers to an executable program exe and is an executive program for uploading and downloading files. go is used as the server of the socket, and desktop application framework Electron is used as the client of the socket. The call-back means that the executable program exe sends the uploading and downloading progress of the corresponding file to the desktop application framework Electron client through the socket, and the purpose of the call-back is to display the uploading and downloading progress on the interface.
In this embodiment, the electronic device (for example, the server/terminal device shown in fig. 1) on which the file upload and download method operates may receive the file upload and download request through a wired connection manner or a wireless connection manner. It should be noted that the wireless connection means may include, but is not limited to, a 3G/4G/5G connection, a WiFi connection, a bluetooth connection, a wimax file uploading/downloading connection, a Zigbee connection, a uwb (ultra wideband) connection, and other wireless connection means now known or developed in the future.
In this embodiment, the desktop application framework Electron starts go through spawn of the node, and the step of generating the executable program exe by go may further include:
the desktop application framework Electron starts go through spawn of the node, and an executable program exe is generated by the go;
connecting a socket, taking the executable program exe as a server and taking the server application as a client;
and starting the task of uploading and downloading.
After the uploading and downloading tasks are started, the uploading and downloading tasks are added, the uploading and downloading tasks are firstly stored into vuex, and then the uploading and downloading tasks are stored into sqlite; sending the uploaded and downloaded tasks to an executable program exe through a socket; and the executable program exe calls back the uploading and downloading progress through the socket and updates vuex.
A node refers to a node. spawn is a module in node.js that is used to start processes. go refers to the go language, a development language.
Step S202, selecting a file by the desktop application framework Electron to upload and download, storing information of the uploaded and downloaded file by vuex, and storing the information of the uploaded and downloaded file into a database sqlite 3.
In this embodiment, uploading and downloading file information may, but is not limited to, include: the file uploading and downloading progress, the uploading and downloading state, the uploading and downloading speed, the file size, the file name, the uploading and downloading completion time, the downloading path, the uploading path, the file ID number, the MD5 value of the file and the like.
The database sqlite3 displays tasks in a paging mode, and 100-200 tasks are set to be one page. The reason why the database sqlite3 is set to display tasks in pages is to avoid the problem that the display tasks are stuck when the number of tasks increases. In the present embodiment, the setup database sqlite3 displays 150 upload and download file tasks per page.
In step S203, the executable program exe establishes a connection with the Electron through the socket.
In this embodiment, the step of establishing a connection between the executable program exe and the desktop application framework Electron through the socket may further include:
acquiring available ports 9000-65539 by a desktop application framework Electron;
the desktop application framework Electron starts an executable program exe through spwan and transmits the executable program exe into available ports 9000-65539 and a sqlite3 database path;
after the executable program exe is started, a socket server is established according to available ports 9000-65539;
the desktop application framework Electron establishes a socket client according to the available ports 9000-65539, and communicates with the executable program exe.
And step S204, the desktop application framework Electron sends the tasks of file uploading and downloading and the user interface display to go, and go executes the program.
And the desktop application framework Electron sends the task of file uploading and the user interface display to go, the go executive program and the desktop application framework Electron send the task of file downloading and the user interface display to go, and the go executive program.
The desktop application framework Electron sends a task of file uploading and a user interface display to go, and the go execution program can further comprise:
s2041, receiving a socket of the uploading task, and transmitting a path of the file to be uploaded.
S2042, creating an uploading thread.
S2043, judging whether the uploading thread is larger than the uploading thread threshold value, putting the task larger than the uploading thread threshold value into a waiting queue for execution, and directly executing the task smaller than the uploading thread threshold value. The uploading thread threshold value can be set according to a network environment, and for example, the number of the uploading thread threshold values can be 3-5. In this embodiment, the number of the cells is 5.
And S2044, sending the current task uploading progress to the desktop application framework Electron through the socket at regular intervals of time, such as 1S.
S2045, when the system detects that the task needs to be suspended, the desktop application framework Electron suspends the uploading task, the executable program exe suspends the thread, and a suspension message is returned through the socket.
S2046, when the system detects that the uploading task needs to be restarted, the desktop application framework Electron restarts the uploading task, the executable program exe judges whether the current execution thread is larger than the uploading thread threshold value, the task larger than the uploading thread threshold value is put into a waiting queue to be executed, and the task smaller than the uploading thread threshold value is directly executed.
The desktop application framework Electron sends a task of file downloading and a user interface display to go, and the go execution program can further comprise:
and S2051, receiving a socket of the downloading task, and inputting a downloading path.
And S2052, creating a downloading thread.
And S2053, judging whether the downloading thread is larger than the downloading thread threshold value, putting the task larger than the downloading thread threshold value into a waiting queue for execution, and directly executing the task smaller than the downloading thread threshold value. The download thread threshold value can be set according to a network environment, and can be 3-5, for example. In this embodiment, the number of the cells is 5.
And S2054, sending the downloading progress to the desktop application framework Electron through the socket at regular time intervals such as 1S.
And S2055, generating a temporary file storage downloading progress every time a file is downloaded.
And S2056, when the system detects that the downloading task needs to be paused or resumed, pausing or resuming the downloading task.
And S2057, the executable program exe reads all unfinished data in the database sqlite and generates a corresponding thread to execute.
In order to reduce the ipc communication frequency of the Electron, the number of executed tasks is controlled, for example, the number is limited to 10 (10 are limited for uploading and downloading) in this embodiment, so that only 10 times of communication is needed to make a round trip or 20 times when the tasks are completely stopped, and the ipc (inter-process communication means interaction between data of two processes) communication frequently blocks the rendering thread of the Electron, which causes the problem of UI incrustation. In some optional implementation manners of the embodiment, the number of go execution programs is set to be 5-20, and in the embodiment, the number of go execution programs is set to be 10.
According to the embodiment, on the basis of the existing Electron, go is used for generating an executable program exe, the communication connection is carried out between the executable program exe and the Electron through socket, the Electron is responsible for sending the uploading and downloading tasks and ui display, go is responsible for executing the program, and sqlite stores the downloading record, so that the file uploading and downloading speed is high, the process consumption is low, the file transmission efficiency is improved through division and cooperation of the Electron, go and sqlite3, and the method can be widely applied to the technical field of file uploading and downloading frequency.
Fig. 3 is a flowchart of the file upload and download program in fig. 2. In some optional implementation manners of this embodiment, as shown in fig. 3, in this embodiment, 10 file upload and download tasks are taken as an example for description, when the file upload and download program is started, the electronic device may further perform the following steps:
and S301, starting a file uploading and downloading program.
S302, judging whether the spawn starting executable program exe succeeds, if so, executing the step S303, otherwise, executing the step S307.
S303, judging whether the socket connection is successful, if so, executing the step S309, otherwise, executing the step S304.
S304, prompting to restart the service.
S305, judging whether the service is restarted successfully or not, if so, executing the step S302, otherwise, executing the step S306.
S306, closing the file uploading and downloading program.
And S307, prompting that the file uploading and downloading program fails to start.
And S308, judging whether the program needs to be restarted, if so, executing the step S301, otherwise, executing the step S306.
S309, waiting for sending the tasks of file uploading and downloading.
According to the application, an executable program exe is generated by using a go, and is in communication connection with an Electron through a socket, so that the problem that the Electron uses js single-thread uploading and downloading is solved, the concurrent uploading and downloading time can be shortened, the pause and the start of fine control are realized, and the problem that the Electron can block the main process and the socket and can be in connection failure is solved.
Fig. 4 is a flowchart for performing file uploading and downloading in fig. 2. In some optional implementations, as shown in fig. 4, a file uploading and downloading process is performed, and the electronic device may perform the following steps:
s401, starting a task of uploading and downloading files.
S402, storing data by vuex. vuex is a state management schema developed specifically for vue. js applications (which employs centralized storage to manage the state of all components of the application and ensures that the state changes in a predictable manner with corresponding rules).
And S403, writing data into the database sqlite 3. The database sqlite3 was chosen because the database sqlite3 supports most SQL commands, a file is a database, and there is no need to install database server software. sqlite3 does not require any database engine. sqlite3 also has full Unicode support (so there is no cross-lingual problem). The database sqlite3 is fast.
S404, selecting 10 tasks and sending the tasks to the executable program exe through the socket.
S405, informing vuex to mark the 10 tasks as activated states.
And S406, executing the executable program exe.
And S407, monitoring the task execution progress.
And S408, completing the execution task.
S409, modifying the database sqlite3, and marking the 10 tasks as completed.
And S410, marking the data related to the 10 tasks in vuex as a completed state.
S411, sending the inactivated vuex task to the executable program exe executable program, and entering step S406.
After one task is completed, selecting an inactivated task from vuex and sending the inactivated task to executable program exe for execution, and keeping executing no more than 10 tasks.
By sending the data to the memory, the data reading and writing speed can be improved.
Fig. 5 is a flowchart for initializing a file upload and download task in fig. 2. In some optional implementations, as shown in fig. 5, in the process for initializing the file uploading/downloading task, the electronic device may perform the following steps:
s501, reading data of the database sqlite 3.
And S502, storing the data into vuex for management.
Fig. 6 is a flowchart of the task of suspending file uploading and downloading in fig. 2. In some optional implementations, as shown in fig. 6, the file uploading and downloading task flow is suspended, and the electronic device may perform the following steps:
s601, suspending the file uploading and downloading task.
And S602, changing the state of the inactivated task into a suspended state.
S603, sending a task suspending instruction to the executable program exe executable program.
S604, executable exe the executable receives an instruction to suspend the task.
And S605, suspending the corresponding activated task.
According to the method and the device, the suspended file uploading and downloading tasks are flexibly set, the user experience can be improved, the tasks which are not activated do not have thread tasks and can be directly suspended, and the tasks which are executed need to wait for the suspension to be suspended successfully and then can be suspended.
Fig. 7 is a flowchart of the task of resuming file upload and download in fig. 2. In some optional implementations, as shown in fig. 7, the electronic device may resume the file uploading and downloading task flow, and perform the following steps:
and S701, recovering the file uploading and downloading tasks.
And S702, sending 10 tasks to the executable program exe for execution.
S703, the executable program exe executes the task activated preferentially.
And S704, monitoring the file uploading and downloading progress.
According to the method and the device, the user experience is improved by setting a certain number of recovery file uploading and downloading tasks, 10 tasks are sent, and page blocking when the data volume is large is avoided.
The application is operational with numerous general purpose or special purpose computing system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet-type devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like. The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware associated with computer readable instructions, which can be stored in a computer readable storage medium, and when executed, the processes of the embodiments of the methods described above can be included. The storage medium may be a non-volatile storage medium such as a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a Random Access Memory (RAM).
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
Example two
With further reference to fig. 8, as an implementation of the method shown in fig. 2, the present application provides an embodiment of a file uploading and downloading apparatus, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 2, and the apparatus may be specifically applied to various electronic devices.
As shown in fig. 8, the file uploading and downloading apparatus 400 according to this embodiment includes: an initiation module 401, a configuration module 402, a connection module 403, and an execution module 404. Wherein:
the starting module 401 is used for enabling the desktop application framework Electron to start go through spawn of the node, and generating an executable program exe from the go;
the configuration module 402 is used for selecting files for uploading and downloading by desktop application framework Electron, storing information of the uploaded and downloaded files by vuex, and storing the information of the uploaded and downloaded files in a database sqlite 3;
the connection module 403 is used for establishing connection between the executable program exe and the desktop application framework Electron through the socket;
and the execution module 404 is used for sending the tasks of file uploading and downloading and the user interface display to go by the desktop application framework Electron, and the go executes the program.
In this embodiment, the file uploading and downloading method shown in the second embodiment is executed on the file uploading and downloading device, and for a specific execution flow, reference is made to the second embodiment, which is not described herein again.
According to the embodiment, on the basis of the existing Electron, go is used for generating an executable program exe, the communication connection is carried out between the executable program exe and the Electron through socket, the Electron is responsible for sending the uploading and downloading tasks and ui display, go is responsible for executing the program, and sqlite stores the downloading record, so that the file uploading and downloading speed is high, the process consumption is low, the file transmission efficiency is improved through division and cooperation of the Electron, go and sqlite3, and the method can be widely applied to the technical field of file uploading and downloading frequency.
Fig. 9 is a schematic structural diagram of another embodiment of a file uploading and downloading device according to the present application. In some optional implementations, as shown in fig. 9, a file uploading and downloading apparatus is provided with a four-layer structure including a front-end UI layer, a rendering process layer, a main process layer, and a go layer. The desktop application framework Electron includes a rendering process and a host process. The front end UI layer is provided with html and css. And the rendering process layer manages the task state and communicates and controls the vuex task through vuex. The main process layer comprises an executable program exe, socket communication and a read-write database. And the go layer is provided with a thread management layer, a file uploading layer, a file downloading layer and a read-write database layer. The database sqlite3 runs through the host process layer and go layer. And generating an executable program exe by using go, performing communication connection with an Electron through a socket, wherein the Electron is responsible for sending an uploading and downloading task and ui display, go is responsible for executing the program, and sqlite stores a downloading record.
EXAMPLE III
In order to solve the technical problem, an embodiment of the present application further provides a computer device. Referring to fig. 10, fig. 10 is a block diagram of a basic structure of a computer device according to the embodiment.
The computer device 6 comprises a memory 61, a processor 62, a network interface 63 communicatively connected to each other via a system bus. It is noted that only the computer device 6 having the component memory 61, the processor 62 and the network interface 63 is shown, but it is understood that not all of the shown components are required to be implemented, and that more or fewer components may be implemented instead. As will be understood by those skilled in the art, the computer device is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The computer device can be a desktop computer, a notebook, a palm computer, a cloud server and other computing devices. The computer equipment can carry out man-machine interaction with a user through a keyboard, a mouse, a remote controller, a touch panel or voice control equipment and the like.
The memory 61 includes at least one type of readable storage medium including a flash memory, a hard disk, a multimedia card, a card type memory (e.g., an SD or D file upload/download memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory 61 may be an internal storage unit of the computer device 6, such as a hard disk or a memory of the computer device 6. In other embodiments, the memory 61 may also be an external storage device of the computer device 6, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the computer device 6. Of course, the memory 61 may also comprise both an internal storage unit of the computer device 6 and an external storage device thereof. In this embodiment, the memory 61 is generally used for storing an operating system installed in the computer device 6 and various application software, such as computer readable instructions of a file uploading and downloading method. Further, the memory 61 may also be used to temporarily store various types of data that have been output or are to be output.
The processor 62 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data Processing chip in some embodiments. The processor 62 is typically used to control the overall operation of the computer device 6. In this embodiment, the processor 62 is configured to execute computer readable instructions stored in the memory 61 or process data, for example, execute computer readable instructions of the file uploading and downloading method.
The network interface 63 may comprise a wireless network interface or a wired network interface, and the network interface 63 is typically used for establishing a communication connection between the computer device 6 and other electronic devices.
According to the embodiment, on the basis of the existing Electron, go is used for generating an executable program exe, the communication connection is carried out between the executable program exe and the Electron through socket, the Electron is responsible for sending the uploading and downloading tasks and ui display, go is responsible for executing the program, and sqlite stores the downloading record, so that the file uploading and downloading speed is high, the process consumption is low, the file transmission efficiency is improved through division and cooperation of the Electron, go and sqlite3, and the method can be widely applied to the technical field of file uploading and downloading frequency.
Example four
The present application further provides another embodiment, which is to provide a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, which can be executed by at least one processor, so as to cause the at least one processor to execute the steps of the file uploading and downloading method.
According to the embodiment, on the basis of the existing Electron, go is used for generating an executable program exe, the communication connection is carried out between the executable program exe and the Electron through socket, the Electron is responsible for sending the uploading and downloading tasks and ui display, go is responsible for executing the program, and sqlite stores the downloading record, so that the file uploading and downloading speed is high, the process consumption is low, the file transmission efficiency is improved through division and cooperation of the Electron, go and sqlite3, and the method can be widely applied to the technical field of file uploading and downloading frequency.
Through the description of the foregoing embodiments, it is clear to those skilled in the art that the method of the foregoing embodiments may be implemented by software plus a necessary general hardware platform, and certainly may also be implemented by hardware, but in many cases, the former is a better implementation. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present application.
It is to be understood that the above-described embodiments are merely illustrative of some, but not restrictive, of the broad invention, and that the appended drawings illustrate preferred embodiments of the invention and do not limit the scope of the invention. This application is capable of embodiments in many different forms and is provided for the purpose of enabling a thorough understanding of the disclosure of the application. Although the present application has been described in detail with reference to the foregoing embodiments, it will be apparent to one skilled in the art that the present application may be practiced without modification or with equivalents of some of the features described in the foregoing embodiments. All equivalent structures made by using the contents of the specification and the drawings of the present application are directly or indirectly applied to other related technical fields and are within the protection scope of the present application.

Claims (10)

1. A file uploading and downloading method is characterized by comprising the following steps:
the desktop application framework Electron starts go through spawn of the node, and the go generates an executable program exe;
selecting a file by a desktop application framework Electron for uploading and downloading, storing information of the uploaded and downloaded file by vuex, and storing the information of the uploaded and downloaded file into a database sqlite 3;
the executable program exe is connected with a desktop application framework Electron through a socket;
and the desktop application framework Electron sends the tasks of file uploading and downloading and the user interface display to go, and go executes the program.
2. The file uploading and downloading method according to claim 1, wherein the uploading and downloading file information comprises:
the file uploading and downloading progress, the uploading and downloading state, the uploading and downloading speed, the file size, the file name, the uploading and downloading completion time, the downloading path, the uploading path, the file ID number and the MD5 value of the file.
3. The file uploading and downloading method according to claim 1, wherein the database sqlite3 paginates tasks of file uploading and downloading, and the tasks of 100-200 file uploading and downloading are set to one page.
4. The file uploading and downloading method according to claim 3, wherein the number of the go execution programs is set to be 5-20.
5. The file uploading and downloading method of claim 1, wherein the desktop application framework Electron starts go through spawn of the node, and the step of generating the executable program exe by go further comprises:
establishing socket connection between the executable program exe and a desktop application framework Electron, taking the executable program exe as a service end of the socket, and taking the desktop application framework Electron as a client end of the socket;
and starting a task of uploading and downloading the file on the desktop application framework Electron.
6. The file uploading and downloading method according to any one of claims 1 to 5, wherein the step of establishing a connection between the executable program exe and a desktop application framework Electron through a socket further comprises:
acquiring available ports 9000-65539 by a desktop application framework Electron;
the desktop application framework Electron starts an executable program exe through spwan and transmits the executable program exe into available ports 9000-65539 and a sqlite3 database path;
after the executable program exe is started, a socket server is established according to available ports 9000-65539;
the desktop application framework Electron establishes a socket client according to the available ports 9000-65539, and communicates with the executable program exe.
7. The file uploading and downloading method according to any one of claims 1 to 5, wherein the desktop application framework Electron sends the task of file uploading and downloading and the user interface display to go, and the step of go executing the program further specifically comprises:
the desktop application framework Electron sends a task of file uploading and a user interface display to go, and go executes a program; and the desktop application framework Electron sends the task of file downloading and the user interface display to go, and go executes the program.
8. A file uploading and downloading device, comprising:
the starting module is used for enabling the desktop application frame Electron to start go through spawn of the node, and the go generates an executable program exe;
the configuration module is used for selecting files for uploading and downloading by the desktop application framework Electron, storing information of the uploaded and downloaded files by vuex, and storing the information of the uploaded and downloaded files into a database sqlite 3;
the connection module is used for establishing connection between the executable program exe and the desktop application framework Electron through a socket;
and the execution module is used for sending the tasks of file uploading and downloading and the user interface display to go by the desktop application framework Electron, and the go executes the program.
9. A computer device comprising a memory having computer readable instructions stored therein and a processor which when executed implements the steps of the file upload and download method according to any of claims 1 to 7.
10. A computer-readable storage medium, wherein computer-readable instructions are stored on the computer-readable storage medium, and when executed by a processor, the computer-readable instructions implement the steps of the file uploading and downloading method according to any one of claims 1 to 7.
CN202210331359.1A 2022-03-31 2022-03-31 File uploading and downloading method and device, computer equipment and storage medium Pending CN114500518A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210331359.1A CN114500518A (en) 2022-03-31 2022-03-31 File uploading and downloading method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210331359.1A CN114500518A (en) 2022-03-31 2022-03-31 File uploading and downloading method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114500518A true CN114500518A (en) 2022-05-13

Family

ID=81488182

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210331359.1A Pending CN114500518A (en) 2022-03-31 2022-03-31 File uploading and downloading method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114500518A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150180963A1 (en) * 2012-08-19 2015-06-25 Box, Inc. Enhancement of upload and/or download performance based on client and/or server feedback information
CN111158690A (en) * 2020-01-02 2020-05-15 北京东土科技股份有限公司 Desktop application framework, construction method, desktop application running method and storage medium
CN112926002A (en) * 2021-03-10 2021-06-08 工银科技有限公司 Service request processing method and device
CN114090593A (en) * 2020-07-30 2022-02-25 中移(苏州)软件技术有限公司 Data synchronous display method, device, terminal and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150180963A1 (en) * 2012-08-19 2015-06-25 Box, Inc. Enhancement of upload and/or download performance based on client and/or server feedback information
CN111158690A (en) * 2020-01-02 2020-05-15 北京东土科技股份有限公司 Desktop application framework, construction method, desktop application running method and storage medium
CN114090593A (en) * 2020-07-30 2022-02-25 中移(苏州)软件技术有限公司 Data synchronous display method, device, terminal and storage medium
CN112926002A (en) * 2021-03-10 2021-06-08 工银科技有限公司 Service request processing method and device

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
CAANDOLL: "【easy-invoices】electron-vue、sqlite3 项目初探", 《HTTPS://SEGMENTFAULT.COM/A/1190000016845718》 *
HUANGBAIHEI: "使用electron-vue+go写一个处理excel表格小软件", 《HTTPS://BLOG.CSDN.NET/HUANGBAIHEI/ARTICLE/DETAILS/106073640》 *
LUOHAIXIAN: "使用Go实现并发切片上传和下载文件", 《HTTPS://WWW.CNBLOGS.COM/LUOHAIXIAN/P/15168526.HTML》 *
YOGURT_CRY: "[个人项目] 用 Electron + Vue3 + Golang 做个一个桌面 Markdown 笔记软件", 《HTTPS://JUEJIN.CN/POST/7056686048058802212》 *

Similar Documents

Publication Publication Date Title
EP3855312A1 (en) Information processing method, device, storage medium, electronic device and system
CN110020323B (en) Page switching method and system for hybrid application, computer equipment and storage medium
EP2755145A1 (en) Webpage browsing method and device, and storage medium
CN104572293A (en) Implementation method of medical image reading system based on BS (Browser/Server) structure
CN111782304B (en) Paging loading data logic control method, device, computer equipment and medium
CN111800462A (en) Micro-service instance processing method and device, computer equipment and storage medium
CN112631910A (en) Front-end testing method and device, computer equipment and storage medium
CN114996619A (en) Page display method and device, computer equipment and storage medium
CN113179188A (en) Service degradation dynamic realization method and device, computer equipment and storage medium
EP4095686A2 (en) Method for switching skin of mini-program page, and electronic device
CN115455058A (en) Cache data processing method and device, computer equipment and storage medium
CN111258800A (en) Page processing method and device and electronic equipment
CN114500518A (en) File uploading and downloading method and device, computer equipment and storage medium
CN111475388A (en) Data push test method and device, computer equipment and storage medium
WO2015074569A1 (en) Method and apparatus for displaying transmission status of cloud documents
CN114968529A (en) Timer implementation method and related product
CN110704157B (en) Application starting method, related device and medium
CN103618961A (en) Method, system and browser for displaying video title
CN110069493B (en) Data processing method, device, computer equipment and storage medium
CN114138401A (en) Container configuration method, device, equipment and medium based on artificial intelligence
CN116521630B (en) Task progress real-time display method and device, computer equipment and storage medium
CN113268300B (en) Information display method and device
CN112631572A (en) Code display method, device, equipment and storage medium based on mobile terminal
CN114879988A (en) Online upgrade method and device, computer equipment and storage medium
CN110795117A (en) Method, system, electronic device and storage medium for updating configuration file

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20220513

RJ01 Rejection of invention patent application after publication