A method of avoiding waste third party cloud memory space
Technical field
The present invention relates to Computer Applied Technology, especially a kind of method for avoiding waste third party cloud memory space.
Background technique
Heap file resource can be generated in the use process of various web application and app application, for example sends multimedia
The Miscellaneous Documents resources such as picture, video, the document that may be attached to when message.Storing these accessory resources over time needs
Want massive storage space.Many products can buy the third party cloud memory space of profession, and more being stored using third party cloud is empty
Between also imply that cost is bigger certainly.
Illustrate the operation for wasting third party cloud memory space so that web application sends the notification message comprising file as an example.
In order to promote user experience, reduction user clicks response time when sending message, generally requires when user chooses file,
Asynchronous that file is uploaded to third party cloud memory space, such user, which clicks, will not need to carry out time-consuming text again when sending message
Part upload operation.If user deletes file, modification file, cancellation message before clicking transmission message and sends, originally uploaded
File to third party cloud memory space will will become discarded record, to waste third party cloud memory space.Or it uses
Family has selected identical file when sending different notification messages, and repetition is uploaded to third party cloud memory space and similarly causes
Waste.
Summary of the invention
The present invention is directed to above-mentioned scene, provides a kind of method for avoiding waste third party cloud memory space.The present invention exists
While guaranteeing user experience, discarded record and duplicate file can be prevented to be uploaded to third party cloud memory space, to reduce cloud
Carrying cost.
It is illustrated so that web application sends the notification message comprising file as an example:
If the file in notification message has in the attribute that server-side saves: file cryptographic Hash, file size, file type,
Whether document storage mode, file network address, file have sent.
When step 1, user's select file, using the cryptographic Hash, size and type of web browser calculation document, and access
Local server inquires the whether existing this document of local server according to file cryptographic Hash, if it exists then by file storage side
Formula is set as local server storage, sets the corresponding network address of local server store path for file network address,
It no longer needs to carry out file upload operation at this time.If it does not exist, then the whether existing this document of third party cloud memory space is inquired, if
In the presence of then the storage of third party cloud memory space is set by document storage mode, third party cloud is set by file network address and is deposited
The corresponding network address in space is stored up, no longer needs to carry out file upload operation at this time.If local server and third party cloud storage are empty
Between this document is all not present, create temp directory in local server, the subdirectory named with the date created under temp directory
The format of A, date are YYYYMMDD, recycle mature piecemeal uploading file that file is uploaded to the catalogue of local server
In A.Local server storage is set by document storage mode after uploading successfully, sets local service for file network address
The corresponding network address of device store path is set as "No" for whether file has sent attribute.
Step 2 obtains document storage mode, behind file network address in step 1, by the cryptographic Hash of file, size and
Type, storage mode, network address are stored to database.User clicks transmission message
The no attribute that sent is set as "Yes", and recipient will access this document according to file network address.The storage mode of file at this time
According to the different situations in step 1, it would be possible to be local server storage or the storage of third party cloud memory space.If storage
When mode is that third party cloud memory space stores, it will not need to carry out other operations to file.If storage mode is local service
When device stores, then upper transmitting file is opened to the system task of third party cloud memory space, this task first step will be according to file
Cryptographic Hash inquires the whether existing identical file of third party cloud memory space again, if it exists then terminated task, and updates text
Part storage mode is the storage of third party cloud memory space, sets the corresponding net of third party cloud memory space for file network address
Network address.Then upper transmitting file is to third party cloud memory space if it does not exist, is the by update document storage mode after uploading successfully
The storage of tripartite's cloud storage space, and the corresponding network address of third party cloud memory space is set by file network address.
Step 3, in step 1 if local server and third party cloud memory space are all not present this document, file at
After function is uploaded to the temp directory of local server, if user selects to delete multimedia file, modification multimedia file, directly
The file of local server storage is deleted or modified.If the transmission of user's cancellation notice message, due to local server storage
File is stored in the subdirectory A named with the date in step 1, and system can open times for deleting file in temp directory daily
Business guarantees that extra file is deleted.
It is as follows to delete temporary catalog file flow of task:
Date C and the date D before three days, format on the day of acquisition current system are all YYYYMMDD, traverse temp directory
Subdirectory traverse the subdirectory if there is the subdirectory of entitled D, obtain the corresponding network of All Files under the subdirectory
Address.According to file network address lookup database, if no record directly delete file, if there is record, according to file whether
Send whether determined property can delete.If it is "No" that whether part, which has sent attribute, file is directly deleted, if "Yes", then
Illustrate there is the file in Message Record to be directed toward the address, this document cannot be deleted.Having the case where record may be due to step 2
In the system task of upper transmitting file to third party cloud memory space upload failure, at this time first by file copy to the son of entitled C
The file network address recorded in catalogue while more new database, being then turned on transmitting file to third party cloud memory space is
System task.
The present invention has the beneficial effect that:
Present invention use is first uploaded to local server, goes up transmitting file again after user confirms and sends message to third party cloud
The method of memory space, prevented user message send before delete file, modification file bring third party memory space and
The waste of flow.
The present invention no longer carries out upload operation, improves efficiency and keep away when there is the file of same file cryptographic Hash to occur
The waste that duplicate file uploads bring third party memory space and flow is exempted from.
Specific embodiment
A method of avoid waste third party cloud memory space that from capable of preventing useless text while guaranteeing user experience
Part and duplicate file are uploaded to third party cloud memory space, to reduce cloud storage cost.
It is illustrated so that web application sends the notification message comprising file as an example:
If the file in notification message has in the attribute that server-side saves: file cryptographic Hash, file size, file type,
Whether document storage mode, file network address, file have sent.
When step 1, user's select file, using the cryptographic Hash, size and type of web browser calculation document, and access
Local server inquires the whether existing this document of local server according to file cryptographic Hash, if it exists then by file storage side
Formula is set as local server storage, sets the corresponding network address of local server store path for file network address,
It no longer needs to carry out file upload operation at this time.If it does not exist, then the whether existing this document of third party cloud memory space is inquired, if
In the presence of then the storage of third party cloud memory space is set by document storage mode, third party cloud is set by file network address and is deposited
The corresponding network address in space is stored up, no longer needs to carry out file upload operation at this time.If local server and third party cloud storage are empty
Between this document is all not present, create temp directory in local server, the subdirectory named with the date created under temp directory
The format of A, date are YYYYMMDD, recycle mature piecemeal uploading file that file is uploaded to the catalogue of local server
In A.Local server storage is set by document storage mode after uploading successfully, sets local service for file network address
The corresponding network address of device store path is set as "No" for whether file has sent attribute.
Step 2 obtains document storage mode, behind file network address in step 1, by the cryptographic Hash of file, size and
Type, storage mode, network address are stored to database.User clicks transmission message
The no attribute that sent is set as "Yes", and recipient will access this document according to file network address.The storage mode of file at this time
According to the different situations in step 1, it would be possible to be local server storage or the storage of third party cloud memory space.If storage
When mode is that third party cloud memory space stores, it will not need to carry out other operations to file.If storage mode is local service
When device stores, then upper transmitting file is opened to the system task of third party cloud memory space, this task first step will be according to file
Cryptographic Hash inquires the whether existing identical file of third party cloud memory space again, if it exists then terminated task, and updates text
Part storage mode is the storage of third party cloud memory space, sets the corresponding net of third party cloud memory space for file network address
Network address.Then upper transmitting file is to third party cloud memory space if it does not exist, is the by update document storage mode after uploading successfully
The storage of tripartite's cloud storage space, and the corresponding network address of third party cloud memory space is set by file network address.
Step 3, in step 1 if local server and third party cloud memory space are all not present this document, file at
After function is uploaded to the temp directory of local server, if user selects to delete multimedia file, modification multimedia file, directly
The file of local server storage is deleted or modified.If the transmission of user's cancellation notice message, due to local server storage
File is stored in the subdirectory A named with the date in step 1, and system can open times for deleting file in temp directory daily
Business guarantees that extra file is deleted.
It is as follows to delete temporary catalog file flow of task:
Date C and the date D before three days, format on the day of acquisition current system are all YYYYMMDD, traverse temp directory
Subdirectory traverse the subdirectory if there is the subdirectory of entitled D, obtain the corresponding network of All Files under the subdirectory
Address.According to file network address lookup database, if no record directly delete file, if there is record, according to file whether
Send whether determined property can delete.If it is "No" that whether part, which has sent attribute, file is directly deleted, if "Yes", then
Illustrate there is the file in Message Record to be directed toward the address, this document cannot be deleted.Having the case where record may be due to step 2
In the system task of upper transmitting file to third party cloud memory space upload failure, at this time first by file copy to the son of entitled C
The file network address recorded in catalogue while more new database, being then turned on transmitting file to third party cloud memory space is
System task.