WO2015062494A1 - Method and device for sdk uploading and downloading of a file - Google Patents

Method and device for sdk uploading and downloading of a file Download PDF

Info

Publication number
WO2015062494A1
WO2015062494A1 PCT/CN2014/089765 CN2014089765W WO2015062494A1 WO 2015062494 A1 WO2015062494 A1 WO 2015062494A1 CN 2014089765 W CN2014089765 W CN 2014089765W WO 2015062494 A1 WO2015062494 A1 WO 2015062494A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
download
uploading
interface
downloaded
Prior art date
Application number
PCT/CN2014/089765
Other languages
French (fr)
Chinese (zh)
Inventor
张劲辉
Original Assignee
北京奇虎科技有限公司
奇智软件(北京)有限公司
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
Priority claimed from CN201310522159.5A external-priority patent/CN103595769B/en
Priority claimed from CN201310522737.5A external-priority patent/CN103595770B/en
Application filed by 北京奇虎科技有限公司, 奇智软件(北京)有限公司 filed Critical 北京奇虎科技有限公司
Publication of WO2015062494A1 publication Critical patent/WO2015062494A1/en

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]
    • 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/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]

Definitions

  • the present invention relates to the field of communications technologies, and in particular, to a method and apparatus for uploading and downloading files based on an SDK (Software Development Kit) of an Android system.
  • SDK Software Development Kit
  • the SDK is a collection of development tools used by software engineers to create application software for specific software packages, software frameworks, hardware platforms, operating systems, etc. It can simply provide an API for an application programming language (Application Programming Interface). Some files of the programming interface, but may also include complex hardware that can communicate with an embedded system.
  • cloud storage integrates a large number of different types of storage devices in the network through application software to jointly provide data storage and service access functions.
  • cloud storage integrates a large number of different types of storage devices in the network through application software to jointly provide data storage and service access functions.
  • the most common business access features provided by cloud storage include data uploading and downloading.
  • the present invention has been proposed to provide an SDK implementation file that overcomes the above problems or at least partially solves the above problems. Upload and download methods and devices.
  • a method for implementing file uploading by an SDK is provided,
  • the SDK is applied to the cloud storage system, and the method includes: receiving a file uploading instruction, acquiring information of the file to be uploaded, and uploading a unified context of the file to be uploaded; and using a member of the application callback information class set in the upload interface.
  • the variable, the plurality of file uploading functions encapsulated in the uploading interface are invoked, so that the plurality of file uploading functions use the unified context environment to upload the file to be uploaded according to the information of the file to be uploaded.
  • an apparatus for uploading a file by an SDK is provided.
  • the SDK is applied to a cloud storage system, and the device includes: a first acquiring module, configured to receive a file uploading instruction, and obtain a file to be uploaded. And a unified context of uploading the file to be uploaded; and an uploading module, configured to invoke a plurality of file uploading functions encapsulated in the uploading interface by using a member variable in the application callback information class set in the uploading interface, so that The plurality of file uploading functions perform uploading of the file to be uploaded using the unified context environment according to the information of the file to be uploaded.
  • a software development kit for implementing file downloading is provided, the software development kit being applied to a cloud storage system, the method comprising: receiving a file download instruction, where the file download instruction is Carrying the information of the file to be downloaded; acquiring the file to be downloaded from the cloud storage end according to the file downloading instruction and the information of the file to be downloaded, and obtaining a unified context for downloading the file to be downloaded; and downloading a member variable in the application callback information class set in the interface, calling a plurality of file download functions encapsulated in the download interface, so that the plurality of file download functions use the unified context environment to download the file to be downloaded .
  • a device for downloading a file by a software development kit comprising: a receiving module, configured to receive a file download instruction, The file downloading instruction carries the information of the file to be downloaded, and the second obtaining module is configured to obtain the file to be downloaded from the cloud storage end according to the file downloading instruction and the information of the file to be downloaded, and obtain the downloading station.
  • Determining a unified context of the downloaded file and downloading a module, by using a member variable in the application callback information class set in the download interface, calling a plurality of file download functions encapsulated in the download interface, so that the multiple The file download function performs downloading of the file to be downloaded using the unified context environment.
  • a computer program comprising computer readable code, when said computer readable code is run on a computing device, causing said computing device to execute said software development kit implementation file Upload and / or download methods.
  • a computer readable medium storing a computer program as described above is provided.
  • the uploading interface and/or downloading interface of the SDK provides a good external cooperation mechanism
  • the uploading interface and/or the downloading interface abstracts and encapsulates the method for uploading files and/or downloading files on the cloud storage end to generate Have member variables and multiple file upload functions and/or download functions in the application callback information class.
  • the SDK When using the SDK for file uploading and/or downloading, obtain a unified context for uploading the file to be uploaded and/or download a unified context for the file to be downloaded, in the unified context, through the upload interface and/or download
  • the member variables in the application callback information class in the interface call the file upload function and/or the file download function to implement the corresponding file upload and / or download, without the developer familiar with the SDK used to upload files and / or download files.
  • the implementation and functions of the interface do not require developers to be familiar with the various task links of uploading files and/or downloading files and the API interfaces used in each task link, thereby greatly reducing the development difficulty of developers and improving development efficiency and development. Quality, speed up development, reduce development costs, and effectively avoid development defects.
  • FIG. 1 is a flow chart showing the steps of a method for implementing file uploading by an SDK according to a first embodiment of the present invention
  • FIG. 2 is a flow chart showing the steps of a method for implementing file uploading by an SDK according to Embodiment 2 of the present invention
  • FIG. 3 is a flow chart showing the steps of a method for implementing file uploading by an SDK according to Embodiment 3 of the present invention
  • FIG. 4 is a flow chart showing the steps of a method for implementing file downloading by an SDK according to Embodiment 4 of the present invention
  • FIG. 5 is a flow chart showing the steps of a method for implementing file downloading by an SDK according to Embodiment 5 of the present invention.
  • FIG. 6 is a flow chart showing the steps of a method for implementing file downloading by an SDK according to Embodiment 6 of the present invention.
  • FIG. 7 is a structural block diagram of an apparatus for implementing file uploading by an SDK according to Embodiment 7 of the present invention.
  • FIG. 8 is a structural block diagram of an apparatus for implementing file uploading by an SDK according to Embodiment 8 of the present invention.
  • FIG. 9 is a structural block diagram of an apparatus for implementing file downloading by an SDK according to Embodiment 9 of the present invention.
  • FIG. 10 is a structural block diagram of an apparatus for implementing file downloading by an SDK according to Embodiment 10 of the present invention.
  • Figure 11 schematically shows a block diagram of a computing device for performing the method according to the invention
  • Fig. 12 schematically shows a storage unit for holding or carrying program code implementing the method according to the invention.
  • FIG. 1 a flow chart of steps of a method for implementing file uploading by an SDK according to a first embodiment of the present invention is shown.
  • the method for implementing file uploading by the SDK in this embodiment is applied to a cloud storage system, and the method includes the following steps:
  • Step S102 Receive a file upload instruction, obtain information of the file to be uploaded, and upload a unified context of the file to be uploaded.
  • the device that uploads the file When a file needs to be uploaded, the device that uploads the file, such as the client, sends a file upload instruction to the cloud storage server.
  • the cloud storage server After receiving the instruction, the cloud storage server obtains the information of the file to be uploaded from the corresponding device, such as the client, such as Information about the file to be uploaded, such as the location of the file to be uploaded, the file size, the location to be uploaded, and so on. More importantly, the cloud storage server also obtains a unified context for uploading files to be uploaded from the device that uploads the file.
  • each call to a function or interface needs to obtain a different context.
  • the unified context needs to be acquired only once, and is used in all subsequent uploading processes of the file to be uploaded.
  • Step S104 Calling a plurality of file uploading functions encapsulated in the uploading interface by uploading the member variables in the application callback information class set in the interface, so that the multiple file uploading functions use the unified context environment according to the information of the file to be uploaded. Report the upload of the uploaded file.
  • the member variable and the multiple file upload function in the application callback information class in the upload interface are determined by analyzing the file uploading process of the cloud storage system, and may only include the basic functions (ie, the core function, the basic function) for implementing the file upload function. Any one of the missing ones can not complete the file upload function), while other function functions can be excluded, such as file upload progress display function, interface prompt function and other functions that do not affect the file upload function can be excluded.
  • the member variables in the callback information class can connect multiple file upload functions according to the execution order of the file upload task, and execute them in the unified context obtained to implement file uploading. As described above, each file upload function uses the acquired unified context environment when it is executed, and does not need to be acquired separately.
  • the upload interface of the SDK provides a good external cooperation mechanism, and the upload interface abstracts and encapsulates the method for uploading files on the cloud storage end to generate the application callback information.
  • the unified context for uploading the file to be uploaded is obtained at one time.
  • the file upload function is called by the member variable in the application callback information class in the upload interface, and the file can be implemented. Uploading, no need for developers to be familiar with the implementation and functions of the interfaces of the various SDKs used to upload files, and no need for developers to be familiar with the various task links of uploading files and the API interfaces used in each task link, thus greatly reducing the development of developers. Difficulty and improved development efficiency and development quality, speed up development, reduce development costs, and effectively avoid development defects.
  • FIG. 2 a flow chart of steps of a method for implementing file uploading by an SDK according to a second embodiment of the present invention is shown.
  • the method for implementing file uploading by the SDK in this embodiment is applied to a cloud storage system, and the method includes the following steps:
  • Step S202 Encapsulating an upload interface of the SDK.
  • a preferred method for packaging an SDK uploading interface includes: analyzing a file uploading process of the cloud storage system, obtaining a basic function of completing a file uploading task from all file uploading functions; abstracting the basic function into an application callback Information class, and according to the basic function definition member variable in the callback information class; use member variables to pass parameters between the basic functions, and determine the calling order of the basic function according to the file upload process; the callback information class is applied and the calling order is determined
  • the basic function is packaged into the upload interface of the SDK.
  • the above analyzes the file uploading process of the cloud storage system, obtains the basic function of completing the file uploading task from all the file uploading functions, and abstracts the basic function into an application callback information class, and defines the application callback information class according to the basic function.
  • the process of the member variable can be manually performed by a person skilled in the art in the actual operation, or can be implemented by a mature artificial intelligence model. Of course, other feasible and appropriate methods are also applicable.
  • the uploading interface of the SDK further encapsulates an uploading thread parameter, and the uploading thread parameter is used to indicate the number of threads used when uploading the file to be uploaded.
  • uploading thread parameters you can flexibly set the number of threads to upload files and improve the flexibility of file uploading.
  • Step S204 The SDK receives the file uploading instruction, and obtains the information of the file to be uploaded and the uploading station. A unified context for the uploaded file.
  • the unified context environment has been used in the subsequent file uploading process of this embodiment.
  • Step S206 The SDK calls a plurality of file upload functions encapsulated in the upload interface by uploading member variables in the application callback information class set in the interface.
  • the upload thread parameter when the upload thread parameter is encapsulated in the upload interface of the SDK, before the step of calling the multiple file upload functions encapsulated in the upload interface by using the member variable in the application callback information class set in the upload interface, : receiving the upload thread parameter setting instruction, according to the upload thread parameter set by the upload thread parameter setting instruction, starting the uploading thread of the upload thread parameter indicating quantity to upload the file to be uploaded.
  • the upload thread parameter in the upload thread parameter setting instruction indicates that five threads are used for file uploading
  • the SDK upload interface starts five threads to receive the file data block of the file to be uploaded and then uploads.
  • the upload thread parameter setting instruction may be set and sent by the device that uploads the file for each file to be uploaded, or may be sent to the SDK by using a default setting value.
  • the upload interface invokes a plurality of file upload functions encapsulated in the upload interface by using member variables and handle parameters in the set application callback information class; wherein the handle parameters are used in multiple files
  • the message is conveyed between the upload functions.
  • Step S208 The SDK uses a plurality of file upload functions to upload the file to be uploaded using the unified context environment according to the information of the file to be uploaded.
  • the file interface is also encapsulated with a file second pass function.
  • the method further includes: calling the file second pass function according to the file to be uploaded. If the file to be uploaded exists on the cloud storage end, the link between the user identifier of the user and the existing file is established; if not, the step S206 is performed.
  • the unified context of uploading the file to be uploaded is obtained at one time, and in the unified context, the file upload function is called by the member variable in the application callback information class in the upload interface.
  • File upload is possible, no need for developers to be familiar with the implementation and functions of the interfaces of the various SDKs used to upload files, and no need to develop
  • the personnel are familiar with the various task links of the uploaded files and the API interfaces used in each task link, thereby greatly reducing the development difficulty of the developer and improving the development efficiency and development quality, speeding up the development, reducing the development cost, and effectively avoiding the development. defect.
  • This embodiment describes a method for uploading a file implementation of the SDK of the present invention by using a specific example, and the method is applied to a cloud storage system.
  • Step 1 Generate an upload interface for the SDK.
  • Required permissions At least the permissions required to generate the SDK, such as the permission configuration of the android application, such as:
  • the Application object is a system component of the android framework.
  • the android program starts, the system creates an application object to store some information about the system.
  • Android system will create an Application class object for each program runtime and only create one, so Application can be said to be a singleton (singleton) mode of a class, and the Application object's health
  • the life cycle is the longest in the entire program, and its life cycle is equal to the life cycle of the program. Because it is a global singleton, so through the Application object for some data transfer, data sharing, data cache and other operations.
  • key(AUTH_NAME, AUTH_KEY, AUTH_SECRET) must be assigned to the corresponding value in com.qihoo.yunpan.sdk.android.config.YunpanSDKConstants.
  • the com.qihoo.yunpan.sdk.android.config.YunpanSDKConstants.setYunpanInter face(IYunpanInterface yunpanInterface) interface ensures the security of the file upload task.
  • the onNewUserToken function and the onUserCookieInvalid function are implemented through the interface, wherein the onNewUserToken function is used to refresh the user token, and the onUserCookieInvalid is used to require the user to re-login when the user cookie fails.
  • Analyze the file uploading process of the cloud storage system obtain the basic function of completing the file uploading task from all the file uploading functions; abstract the basic function into the application callback information class, and define the member variables in the application callback information class according to the basic function; The member variable is used to pass parameters between the basic functions, and the calling sequence of the basic function is determined according to the file uploading process; the application callback information class and the basic function that determines the calling sequence are encapsulated into an SDK uploading interface. For example, when the cloud storage system uploads a file, the client sends a file upload instruction to upload the file; and after receiving the file upload instruction, the cloud storage server learns that there is a file upload task, and starts to obtain the file data block.
  • the obtained file data block is stored to the specified location according to the file upload instruction.
  • each function corresponding to the uploaded data including file name, size, location, file context, file data, etc.
  • Each function corresponding to the specified position can be regarded as a basic function, abstracting and encapsulating these basic functions, and finally generating an upload interface of the SDK.
  • the abstracted application callback information class is:
  • the ActionType (message type enumeration) is com.qihoo.yunpan.sdk.android.task.TransferStatus.ActionType, and its values include:
  • the package can be encapsulated as an upload interface.
  • the upload progress step size can also be set in the upload interface: (default is 5% trigger once, minimum 1 and maximum 20), and the position of the returned data set can be set by calling setProgressStep() and getProgressStep().
  • the current task can also be set in the upload interface: (If restarting, restart the current task in the thread container), the current task can be stopped by calling setIsRun(false).
  • the number of threads in a single task runtime can also be set in the upload interface: (default is 1, maximum 5), which can be set by calling setUploadThreadNum (upload task thread).
  • setUploadThreadNum upload task thread
  • the constructor is as follows:
  • Parameter 2 (name: passWord, type: String, description: password)
  • the constructor is as follows:
  • Parameter 2 (name: passWord, type: String, description: password)
  • Parameter 3 (name: captcha, type: String, description: the verification code entered by the user)
  • Parameter 4 (name: sc, type: String, description: sc parameter returned by the server)
  • the constructor is as follows:
  • Pagination function (Two simultaneous settings take effect, the default is all from 0)
  • the constructor is as follows:
  • One or more of the other major cloud disk SDK methods may be encapsulated into the upload interface in an optional manner to provide a better user experience for uploading files.
  • Step 2 Upload the file using the generated SDK upload interface.
  • a process for uploading a file using the upload interface generated in step one is as shown in FIG. 3, and the process includes:
  • Step S302 Receive a file upload instruction, and the upload task starts.
  • Step S304 The file upload function in the SDK upload interface calculates a hash value of the file to be uploaded.
  • Step S306 The file upload function application file upload task in the SDK upload interface.
  • Step S308 The file upload function in the SDK uploading interface determines whether the file data to be uploaded already exists. If not, step S310 is performed; if yes, step S318 is performed.
  • Step S310 The file upload function in the SDK upload interface acquires file block information of the file to be uploaded.
  • Step S312 The file upload function in the SDK uploading interface determines whether the file upload is completed. If yes, step S314 is performed; if not, the file upload fails.
  • Step S314 The file upload function in the SDK uploading interface confirms that all the file data of the file to be uploaded is completely uploaded, and step S318 is performed.
  • Step S316 The file upload function in the SDK upload interface confirms that the upload task is completed.
  • Step S318 The file upload function in the SDK upload interface prompts that the upload is completed.
  • the task of uploading files through the SDK is realized on the mobile terminal of the android system, the development difficulty of the mobile terminal developer is greatly reduced, the development efficiency and development quality of the mobile terminal are improved, the development speed is accelerated, and the development speed is lowered.
  • the development cost effectively avoids development defects.
  • FIG. 4 a flow chart of steps of a method for implementing file downloading by an SDK according to Embodiment 4 of the present invention is shown.
  • the method for implementing file downloading by the SDK in this embodiment is applied to a cloud storage system, and the method includes the following steps:
  • Step S402 Receive a file download instruction.
  • the file download instruction carries information about the file to be downloaded.
  • the client When the client needs to download the file, it sends a file download command to the cloud storage server, where the command carries information about the file to be downloaded, such as the location of the file to be downloaded, the file size, the location to be stored, and the like.
  • the cloud storage server obtains the information of the files to be downloaded from the file download instruction.
  • Step S404 Obtain a file to be downloaded from the cloud storage end according to the file download instruction and the information of the file to be downloaded, and obtain a unified context for downloading the file to be downloaded.
  • the cloud storage system includes a client and a cloud, and the cloud includes at least one server for storing data. In the embodiment of the present invention, it is simply referred to as a cloud storage terminal, and the cloud storage terminal stores files to be downloaded.
  • the cloud storage server obtains a unified context environment for downloading the file to be downloaded when the file to be downloaded is obtained, and the unified context is obtained. It only needs to be obtained once and used in all subsequent downloads of the file to be downloaded.
  • Step S406 Calling a plurality of file download functions encapsulated in the download interface by using a member variable in the application callback information class set in the download interface, so that the plurality of file download functions use the unified context environment to download the file to be downloaded.
  • the member variable and the multiple file download function in the application callback information class in the download interface are determined by analyzing the file downloading process of the cloud storage system, and may only include the basic functions (ie, the core function, the basic function) for implementing the file download function.
  • the lack of any of the files can not complete the file download function), for example, to obtain the corresponding data of the downloaded file (including file name, size, location, file context, file data, etc.) and the data according to the downloaded file. Download the file to each function corresponding to the specified location; other functions can be excluded, such as file download progress display function, interface prompt function, etc. Functions that do not affect the file download function can be excluded.
  • the member variables in the application callback information class can connect multiple file download functions according to the execution order of the file download task, execute sequentially in the acquired unified context environment, and implement file download. As described above, each file download function uses the acquired unified context environment when it is executed, and does not need to be acquired sequentially.
  • the download interface of the SDK provides a better external cooperation mechanism
  • the download interface The port abstracts and encapsulates the method of downloading files from the cloud storage terminal, and generates a member variable and a plurality of file download functions in the application callback information class.
  • the unified context for downloading the file to be downloaded is obtained at one time.
  • the file download function is called by the member variable in the application callback information class in the download interface, and the file can be implemented. Download, no need for developers to be familiar with the implementation and function of the interface of each SDK used to download files, and no need for developers to be familiar with the various task links of downloading files and API interfaces used in each task link, thus greatly reducing developer development. Difficulty and improved development efficiency and development quality, speed up development, reduce development costs, and effectively avoid development defects.
  • FIG. 5 a flow chart of steps of a method for implementing file downloading by an SDK according to Embodiment 5 of the present invention is shown.
  • the method for implementing file downloading by the SDK in this embodiment is applied to a cloud storage system, and the method includes the following steps:
  • Step S502 Encapsulating the download interface of the SDK.
  • a preferred method for packaging the SDK download interface includes: analyzing a file downloading process of the cloud storage system, obtaining a basic function of completing a file download task from all file download functions; abstracting the basic function into an application callback Information class, and according to the basic function definition member variable in the callback information class; use member variables to pass parameters between the basic functions, and determine the calling order of the basic function according to the file download process; the callback information class is applied and the calling order is determined
  • the basic function is packaged into the download interface of the SDK.
  • the above analyzes the file downloading process of the cloud storage system, obtains the basic function of completing the file download task from all file download functions, and abstracts the basic function into an application callback information class, and defines the application callback information class according to the basic function.
  • the process of the member variable can be manually performed by a person skilled in the art in the actual operation, or can be implemented by a mature artificial intelligence model. Of course, other feasible and appropriate methods are also applicable.
  • the download interface of the SDK further encapsulates a download thread parameter, and the download thread parameter is used to indicate the number of threads used when downloading the file to be downloaded.
  • Step S504 The SDK receives a file download instruction, where the file download instruction carries information of the file to be downloaded.
  • Step S506 The SDK obtains the file to be downloaded from the cloud storage end according to the file download instruction and the information of the file to be downloaded, and obtains a unified context environment for downloading the file to be downloaded.
  • This unified context environment has been used throughout the subsequent file downloading process of this embodiment.
  • the SDK when the download thread parameter is encapsulated in the download interface of the SDK, the SDK obtains the file to be downloaded from the cloud storage terminal according to the file download instruction and the information of the file to be downloaded, and obtains a unified context for downloading the file to be downloaded.
  • the method further includes: receiving a download thread parameter setting instruction, and starting a download thread of the number of indications of the download thread parameter to download the file to be downloaded according to the download thread parameter set by the download thread parameter setting instruction. For example, if the download thread parameter in the download thread parameter setting instruction indicates that the file is downloaded using 5 threads, the SDK download interface starts 5 threads to obtain the file data block of the file to be downloaded from the cloud storage end, and then downloads the file.
  • the download thread parameter setting instruction may be set and sent by the device that downloads the file for each file to be downloaded, or may be sent to the SDK by using a default setting value.
  • Step S508 The SDK calls a plurality of file download functions encapsulated in the download interface by downloading member variables in the application callback information class set in the interface.
  • the download interface invokes a plurality of file download functions encapsulated in the download interface by using a member variable and a handle parameter in the set application callback information class; wherein the handle parameter is used in multiple Messages are sent between file download functions.
  • Step S510 The SDK uses a plurality of file download functions to download the file to be downloaded using the unified context.
  • the download interface is also encapsulated with a download history function.
  • the method further includes: calling the download history function encapsulated in the download interface by using a member variable in the application callback information class in the download interface, The download history function determines whether the client that sent the file download instruction has downloaded the file to be downloaded; if it has been downloaded, it determines whether the downloaded file to be downloaded in the client is valid; if it is valid, the download of the file to be downloaded is ended. If it is invalid or if the file to be downloaded has not been downloaded, step S506 is performed. By downloading the history function, Can effectively avoid repeated downloads of files.
  • the unified context for downloading the file to be downloaded is obtained at one time, and in the unified context, the file download function is invoked by using the member variable in the application callback information class in the download interface.
  • File download can be realized, no need for developers to be familiar with the implementation and functions of the interfaces of each SDK used to download files, and no need for developers to be familiar with the various task links of downloading files and the API interfaces used in each task link, thus greatly reducing the number of The development difficulty of developers and the improvement of development efficiency and development quality, speed up development, reduce development costs, and effectively avoid development defects.
  • This embodiment describes a method for downloading the SDK implementation file of the present invention by using a specific example, and the method is applied to a cloud storage system.
  • Step 1 Generate the download interface of the SDK.
  • Required permissions At least the permissions required to generate the SDK, such as the permission configuration of the android application, such as:
  • the Application object is a system component of the android framework.
  • the android program starts, the system creates an application object to store some information about the system.
  • Android system will create an Application class object for each program runtime and only create one, so Application can be said to be a singleton (singleton) pattern of a class, and the Application object's life cycle is the longest in the entire program, it The life cycle is equal to the life cycle of this program. Because it is a global singleton, so through the Application object for some data transfer, data sharing, data cache and other operations.
  • key(AUTH_NAME, AUTH_KEY, AUTH_SECRET) must be assigned to the corresponding value in com.qihoo.yunpan.sdk.android.config.YunpanSDKConstants.
  • the com.qihoo.yunpan.sdk.android.config.YunpanSDKConstants.setYunpanInterface(IYunpanInterface yunpanInterface) interface ensures the security of the file download task.
  • the onNewUserToken function and the onUserCookieInvalid function are implemented through the interface, wherein the onNewUserToken function is used to refresh the user token, and the onUserCookieInvalid is used to require the user to re-login when the user cookie fails.
  • Analyze the file download process of the cloud storage system obtain the basic function of completing the file download task from all the file download functions; abstract the basic function into the application callback information class, and according to the basis This function defines the member variables in the application callback information class; uses member variables to pass parameters between the basic functions, and determines the calling order of the basic functions according to the file downloading process; encapsulates the application callback information class and the basic functions that determine the calling order into SDKs. Download interface. For example, when the cloud storage system downloads the file, the client sends a file download instruction, and after receiving the file download instruction, the cloud storage server learns that there is a file download task, starts to acquire the file data block, and then according to the file download instruction. The obtained file data block is downloaded to the specified location.
  • each function corresponding to the downloaded data (including file name, size, location, file context, file data, etc.) is obtained, and the file is downloaded according to the data related to the downloaded file.
  • Each function corresponding to the specified position can be regarded as a basic function, and these basic functions are abstracted and encapsulated, and finally the download interface of the SDK is generated.
  • the abstracted application callback information class is:
  • the ActionType (message type enumeration) is com.qihoo.yunpan.sdk.android.task.TransferStatus.ActionType, and its values include:
  • Parameter 3 (name: download_handler, type: Handler, description: convey message)
  • the package interface can be provided as a download interface.
  • the download progress step size can also be set in the download interface: (default is 5% trigger once, minimum 1 and maximum 20), and the position of the returned data set can be set by calling setProgressStep() and getProgressStep().
  • the current task can also be set in the download interface: (If restarting, restart the current task in the thread container), the current task can be stopped by calling setIsRun(false).
  • the number of threads in a single task runtime can also be set in the download interface: (default is 1, maximum 5), which can be set by calling setDownloadThreadNum.
  • the download task of the SDK package supports the JAVA standard multi-threaded environment.
  • the constructor is as follows:
  • Parameter 2 (name: passWord, type: String, description: password)
  • the constructor is as follows:
  • Parameter 2 (name: passWord, type: String, description: password)
  • Parameter 3 (name: captcha, type: String, description: the verification code entered by the user)
  • Parameter 4 (name: sc, type: String, description: sc parameter returned by the server)
  • the constructor is as follows:
  • Pagination function (Two simultaneous settings take effect, the default is all from 0)
  • One or more of the other major cloud disk SDK methods may be encapsulated into the download interface in an optional manner to provide a better user experience for downloading files.
  • Step 2 Download the file using the generated SDK download interface.
  • a process for downloading a file using the download interface generated in step one is as shown in FIG. 6, and the process includes:
  • Step S602 Receive a file download instruction, and the download task starts.
  • Step S604 The file download function in the SDK download interface acquires the download task information.
  • the obtained download task information includes: information of the file to be downloaded and a file to be downloaded. A context.
  • Step S606 The file download function in the SDK download interface determines whether the file data to be downloaded exists locally in the client. If not, step S608 is performed; if yes, step S612 is performed.
  • Step S608 The file download function in the SDK download interface acquires file block information of the file to be downloaded.
  • Step S610 If the download of the file is completed, go to step S612; otherwise, the file download fails.
  • Step S612 The file download function in the SDK download interface prompts that the download is completed.
  • the task of downloading files through the SDK is realized on the mobile terminal of the android system, the development difficulty of the mobile terminal developer is greatly reduced, the development efficiency and development quality of the mobile terminal are improved, the development speed is accelerated, and the development speed is lowered.
  • the development cost effectively avoids development defects.
  • FIG. 7 a block diagram of a device for implementing file uploading by an SDK according to Embodiment 7 of the present invention is shown.
  • the SDK in the device for uploading a file in the SDK of this embodiment is applied to a cloud storage system, and the device includes:
  • the first obtaining module 702 is configured to receive a file uploading instruction, obtain the information of the file to be uploaded, and upload a unified context of the file to be uploaded; the uploading module 704 is configured to use the application callback information class set in the uploading interface.
  • the member variable invokes multiple file upload functions encapsulated in the upload interface, so that multiple file upload functions use the unified context to upload the file to be uploaded according to the information of the file to be uploaded.
  • the uploading interface of the SDK provides a good external cooperation mechanism.
  • the uploading interface abstracts and encapsulates the method for uploading files on the cloud storage end, and generates member variables and multiple file uploads in the application callback information class. function.
  • the unified context for uploading the file to be uploaded is obtained at one time.
  • the file upload function is called by the member variable in the application callback information class in the upload interface, and the file can be implemented.
  • FIG. 8 there is shown a structural block diagram of an apparatus for implementing file uploading by an SDK according to Embodiment 8 of the present invention.
  • the SDK in the device for uploading the file in the embodiment of the present invention is applied to the cloud storage system, and the device includes: a first obtaining module 802, configured to receive a file uploading instruction, obtain information of the file to be uploaded, and upload the file to be uploaded.
  • the unified context environment; the uploading module 804 is configured to invoke multiple file uploading functions encapsulated in the uploading interface by uploading the member variables in the application callback information class set in the interface, so that multiple file uploading functions are based on the information of the file to be uploaded. , use the unified context to upload files to be uploaded.
  • the device for uploading the file in the SDK of the embodiment further includes: a first encapsulating module 806, configured to pre-package the plurality of file uploading functions in the uploading interface in the following manner: a file uploading process to the cloud storage system Analyze, obtain the basic function of completing the file upload task from all file upload functions; abstract the basic function into the application callback information class, and define the member variables in the application callback information class according to the basic function; use member variables to pass between the basic functions Parameters, and determine the calling order of the basic function according to the file uploading process; package the application callback information class and the basic function that determines the calling sequence into an upload interface.
  • a file uploading process to the cloud storage system Analyze, obtain the basic function of completing the file upload task from all file upload functions; abstract the basic function into the application callback information class, and define the member variables in the application callback information class according to the basic function; use member variables to pass between the basic functions Parameters, and determine the calling order of the basic function according to the
  • the uploading interface further includes an uploading thread parameter.
  • the device for uploading the file in the SDK of the embodiment further includes: a first thread setting module 808, configured to upload an application callback information class in the uploading module 804 through the uploading interface.
  • a first thread setting module 808 configured to upload an application callback information class in the uploading module 804 through the uploading interface.
  • receiving the upload thread parameter setting instruction starting the upload thread parameter set by the upload thread parameter setting instruction, starting the upload thread of the upload thread parameter indicating the number to be uploaded.
  • File upload before calling the file upload function encapsulated in the upload interface, receiving the upload thread parameter setting instruction, starting the upload thread parameter set by the upload thread parameter setting instruction, starting the upload thread of the upload thread parameter indicating the number to be uploaded.
  • the uploading module 804 calls a plurality of file uploading functions encapsulated in the uploading interface by using a member variable in the application callback information class set in the uploading interface: by using the uploading interface by using the set application callback information class Member variables and handle parameters, called in the upload interface encapsulated Multiple file upload functions; where the handle parameters are used to convey messages between multiple file upload functions.
  • the file uploading function is further encapsulated in the uploading interface.
  • the device for uploading the file in the SDK of the embodiment further includes: a second transmitting module 810, configured to receive the file uploading instruction in the first obtaining module 802, and obtain the file to be uploaded.
  • the file second pass function is used to determine whether the file to be uploaded exists on the cloud storage end according to the information of the file to be uploaded; if the file to be uploaded already exists on the cloud storage end, Establish a link between the user's user ID and the existing file.
  • the device for uploading a file in the SDK of the embodiment is used to implement the method for uploading the corresponding SDK in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, and details are not described herein again.
  • FIG. 9 a block diagram of a device for implementing file downloading by an SDK according to Embodiment 9 of the present invention is shown.
  • the SDK in the device for implementing file downloading in the SDK of this embodiment is applied to a cloud storage system, and the device includes:
  • the receiving module 902 is configured to receive a file downloading instruction, where the file downloading instruction carries the information of the file to be downloaded, and the second obtaining module 904 is configured to obtain the file to be downloaded from the cloud storage end according to the file downloading instruction and the information of the file to be downloaded. And obtaining a unified context environment for downloading the file to be downloaded; the downloading module 906 is configured to invoke multiple file download functions encapsulated in the download interface by using a member variable in the application callback information class set in the download interface, so that multiple The file download function uses a unified context to download the files to be downloaded.
  • the download interface of the SDK provides a good external cooperation mechanism.
  • the download interface abstracts and encapsulates the method for downloading files on the cloud storage end, and generates member variables and multiple file downloads in the application callback information class. function.
  • the unified context for downloading the file to be downloaded is obtained at one time.
  • the file download function is called by the member variable in the application callback information class in the download interface, and the file can be implemented. Download, no need for developers to be familiar with the implementation and functions of the interfaces of the various SDKs used to download files, nor the need for developers to be familiar with the various task links and task links of downloading files.
  • the API interface is used, which greatly reduces the development difficulty of developers and improves development efficiency and development quality, speeds up development, reduces development costs, and effectively avoids development defects.
  • FIG. 10 a block diagram showing the structure of an apparatus for implementing file downloading by an SDK according to Embodiment 10 of the present invention is shown.
  • the SDK in the device for downloading the file in the embodiment of the present invention is applied to the cloud storage system, and the device includes: a receiving module 1002, configured to receive a file downloading instruction, where the file downloading instruction carries information of the file to be downloaded; and the second acquiring module 1004, configured to obtain a file to be downloaded from the cloud storage terminal according to the file downloading instruction and the information to be downloaded, and obtain a unified context for downloading the file to be downloaded; and the downloading module 1006 is configured to download the application set in the interface.
  • the member variable in the callback information class calls multiple file download functions encapsulated in the download interface, so that multiple file download functions use a unified context to download the file to be downloaded.
  • the apparatus for downloading the file of the SDK in this embodiment further includes: a second encapsulating module 1008, configured to pre-package the plurality of file downloading functions in the upper downloading interface by: performing a file downloading process of the cloud storage system Analysis, get the basic function of completing the file download task from all file download functions; abstract the basic function into the application callback information class, and define the member variables in the callback information class according to the basic function; use the member variable to pass the parameters between the basic functions And according to the file download process to determine the calling order of the basic function; the application callback information class and the basic function that determines the calling sequence are packaged into a download interface.
  • a second encapsulating module 1008 configured to pre-package the plurality of file downloading functions in the upper downloading interface by: performing a file downloading process of the cloud storage system Analysis, get the basic function of completing the file download task from all file download functions; abstract the basic function into the application callback information class, and define the member variables in the callback information class according to the basic function; use the member variable to
  • the download interface further includes a download history function
  • the device for downloading the file in the SDK of the embodiment further includes: an effective determining module 1010, configured to use the application in the download interface after the receiving module 1002 receives the file download command Calling the member variable in the information class, calling the download history function encapsulated in the download interface, and determining whether the client that sent the file download instruction has downloaded the file to be downloaded by downloading the history function; if it has been downloaded, determining the client Whether the downloaded file to be downloaded is valid; if it is valid, the download of the file to be downloaded is ended; if it is invalid or if the file to be downloaded has not been downloaded, the second obtaining module 1004 is entered.
  • an effective determining module 1010 configured to use the application in the download interface after the receiving module 1002 receives the file download command Calling the member variable in the information class, calling the download history function encapsulated in the download interface, and determining whether the client that sent the file download instruction has downloaded the file to be downloaded by downloading the history function; if
  • the downloading interface further includes a downloading thread parameter;
  • the device for downloading the file in the SDK of the embodiment further includes: a second thread setting module 1012, configured to be in the second obtaining module 1004 Obtaining a file to be downloaded from the cloud storage terminal according to the file downloading instruction and the information of the file to be downloaded, and obtaining a downloading thread parameter setting instruction according to the downloading thread parameter setting instruction before obtaining the unified context environment for downloading the file to be downloaded The parameter starts the download thread parameter indicating the number of download threads to download the file to be downloaded.
  • the downloading module 1006 invokes a plurality of file download functions encapsulated in the download interface by using a member variable in the application callback information class set in the download interface: by using the downloaded interface in the set application callback information class The member variable and the handle parameter call multiple file download functions encapsulated in the download interface; wherein the handle parameter is used to convey a message between multiple file download functions.
  • the apparatus for downloading the file in the SDK of the embodiment is used to implement the method for downloading the corresponding SDK in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, and details are not described herein again.
  • the SDK implementation file uploading and/or downloading scheme provided herein is not inherently related to any particular computer, virtual system, or other device.
  • Various general purpose systems can also be used with the teaching based on the teachings herein. According to the above description, it is obvious that the structure required to construct the system having the solution of the present invention is obvious.
  • the invention is not directed to any particular programming language. It is to be understood that the invention may be embodied in a variety of programming language, and the description of the specific language has been described above in order to disclose the preferred embodiments of the invention.
  • modules in the devices of the embodiments can be adaptively changed and placed in one or more devices different from the embodiment.
  • the modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components.
  • any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed, or All processes or units of the device are combined.
  • Each feature disclosed in this specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose.
  • the various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof.
  • a microprocessor or digital signal processor may be used in practice to implement some or all of the functionality of some or all of the components of the SDK implementation file uploading in accordance with embodiments of the present invention.
  • the invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein.
  • a program implementing the invention may be stored on a computer readable medium or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
  • Figure 11 illustrates a computing device, such as an application server, that can implement file upload and/or download in accordance with the SDK of the present invention.
  • the server conventionally includes a processor 1110 and a computer program product or computer readable medium in the form of a memory 1120.
  • the memory 1120 may be an electronic memory such as a flash memory, an EEPROM (Electrically Erasable Programmable Read Only Memory), an EPROM, a hard disk, or a ROM.
  • Memory 1120 has a memory space 1130 for program code 1131 for performing any of the method steps described above. For example, storage space 1130 for program code Each program code 1131 for implementing various steps in the above method may be included.
  • the program code can be read from or written to one or more computer program products.
  • Such computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks.
  • Such a computer program product is typically a portable or fixed storage unit as described with reference to FIG.
  • the storage unit may have a storage section, a storage space, and the like arranged similarly to the storage 1120 in the server of FIG.
  • the program code can be compressed, for example, in an appropriate form.
  • the storage unit includes computer readable code 1131', i.e., code that can be read by, for example, a processor such as 1110, which when executed by a server causes the server to perform various steps in the methods described above.

Abstract

The present invention provides a method and device for SDK uploading and downloading of a file, the SDK being used for a cloud storage system, and the method for SDK uploading of a file comprising: receiving a file upload command, obtaining information of the file to be uploaded, and uploading the uniform context of said file to be uploaded; by means of the application callback information class member variable which is set in the upload interface, invoking a plurality of file upload functions encapsulated in said upload interface, making said plurality of file upload functions be based on said information of the file to be uploaded, and using said uniform context to upload said file to be uploaded. The present invention significantly reduces difficulty for developers and raises the efficiency and quality of development, accelerates its speed, reduces its cost, and effectively prevents defects.

Description

SDK实现文件上传、下载的方法与装置Method and device for implementing file uploading and downloading by SDK 技术领域Technical field
本发明涉及通信技术领域,特别是涉及一种基于Android系统的SDK(Software Development Kit,软件开发工具包)实现文件上传、下载的方法与装置。The present invention relates to the field of communications technologies, and in particular, to a method and apparatus for uploading and downloading files based on an SDK (Software Development Kit) of an Android system.
背景技术Background technique
SDK是一些被软件工程师用于为特定的软件包、软件框架、硬件平台、操作系统等创建应用软件的开发工具的集合,它可以简单地为某个程序设计语言提供API(Application Programming Interface,应用程序编程接口)的一些文件,但也可能包括能与某种嵌入式系统通讯的复杂的硬件。The SDK is a collection of development tools used by software engineers to create application software for specific software packages, software frameworks, hardware platforms, operating systems, etc. It can simply provide an API for an application programming language (Application Programming Interface). Some files of the programming interface, but may also include complex hardware that can communicate with an embedded system.
随着云存储技术的发展,SDK越来越多地被用于开发与云存储相关的应用中。云存储通过集群应用、网格技术或分布式文件系统等功能,将网络中大量各种不同类型的存储设备通过应用软件集合起来协同工作,共同对外提供数据存储和业务访问功能。目前,云存储提供的最常用的业务访问功能包括数据上传和下载。开发人员在使用现有的SDK进行云存储的上传任务和下载任务的开发时,不但需要熟悉上传和下载所使用的各个SDK的接口的实现方式和功能,更需要熟悉上传和下载的各个任务环节,并能够正确选择各个任务环节所使用的API接口。With the development of cloud storage technology, SDKs are increasingly being used to develop applications related to cloud storage. Through the functions of cluster application, grid technology, or distributed file system, cloud storage integrates a large number of different types of storage devices in the network through application software to jointly provide data storage and service access functions. Currently, the most common business access features provided by cloud storage include data uploading and downloading. When developers use the existing SDK to develop cloud storage upload tasks and download tasks, they not only need to be familiar with the implementation and functions of the interfaces of each SDK used for uploading and downloading, but also need to be familiar with the various tasks of uploading and downloading. And can correctly select the API interface used by each task link.
但是,这种开发方式一方面对开发人员要求较高,造成开发困难,开发速度慢,开发成本高;另一方面,可能因为API接口选择的不恰当,造成开发出的任务效率低下,缺陷较多,需要后续不断进行版本升级和改进。However, this kind of development method has higher requirements for developers, resulting in development difficulties, slow development speed, and high development cost. On the other hand, due to the inappropriate selection of API interfaces, the development tasks are inefficient and the defects are relatively poor. More, you need to continue to upgrade and improve the version.
发明内容Summary of the invention
鉴于上述现有的SDK实现文件上传时,开发速度慢,开发成本高,效率低下,缺陷较多的问题,提出了本发明以便提供一种克服上述问题或者至少部分地解决上述问题的SDK实现文件上传、下载的方法与装置。In view of the above-mentioned existing SDK implementation file uploading, the development speed is slow, the development cost is high, the efficiency is low, and the defects are more. The present invention has been proposed to provide an SDK implementation file that overcomes the above problems or at least partially solves the above problems. Upload and download methods and devices.
依据本发明的一个方面,提供了一种SDK实现文件上传的方法,所述 SDK应用于云存储系统,所述方法包括:接收文件上传指令,获取待上传文件的信息及上传所述待上传文件的统一上下文环境;以及通过上传接口中设定的应用回调信息类中的成员变量,调用所述上传接口中封装的多个文件上传函数,使所述多个文件上传函数根据所述待上传文件的信息,使用所述统一上下文环境进行所述待上传的文件的上传。According to an aspect of the present invention, a method for implementing file uploading by an SDK is provided, The SDK is applied to the cloud storage system, and the method includes: receiving a file uploading instruction, acquiring information of the file to be uploaded, and uploading a unified context of the file to be uploaded; and using a member of the application callback information class set in the upload interface. The variable, the plurality of file uploading functions encapsulated in the uploading interface are invoked, so that the plurality of file uploading functions use the unified context environment to upload the file to be uploaded according to the information of the file to be uploaded.
根据本发明的另一方面,提供了一种SDK实现文件上传的装置,所述SDK应用于云存储系统,所述装置包括:第一获取模块,用于接收文件上传指令,获取待上传文件的信息及上传所述待上传文件的统一上下文环境;以及上传模块,用于通过上传接口中设定的应用回调信息类中的成员变量,调用所述上传接口中封装的多个文件上传函数,使所述多个文件上传函数根据所述待上传文件的信息,使用所述统一上下文环境进行所述待上传的文件的上传。According to another aspect of the present invention, an apparatus for uploading a file by an SDK is provided. The SDK is applied to a cloud storage system, and the device includes: a first acquiring module, configured to receive a file uploading instruction, and obtain a file to be uploaded. And a unified context of uploading the file to be uploaded; and an uploading module, configured to invoke a plurality of file uploading functions encapsulated in the uploading interface by using a member variable in the application callback information class set in the uploading interface, so that The plurality of file uploading functions perform uploading of the file to be uploaded using the unified context environment according to the information of the file to be uploaded.
根据本发明的再一方面,提供了一种软件开发工具包实现文件下载的方法,所述软件开发工具包应用于云存储系统,所述方法包括:接收文件下载指令,所述文件下载指令中携带有待下载文件的信息;根据所述文件下载指令和所述待下载文件的信息,从云存储端获取所述待下载文件,并且,获取下载所述待下载文件的统一上下文环境;以及通过下载接口中设定的应用回调信息类中的成员变量,调用所述下载接口中封装的多个文件下载函数,使所述多个文件下载函数使用所述统一上下文环境进行所述待下载文件的下载。According to still another aspect of the present invention, a software development kit for implementing file downloading is provided, the software development kit being applied to a cloud storage system, the method comprising: receiving a file download instruction, where the file download instruction is Carrying the information of the file to be downloaded; acquiring the file to be downloaded from the cloud storage end according to the file downloading instruction and the information of the file to be downloaded, and obtaining a unified context for downloading the file to be downloaded; and downloading a member variable in the application callback information class set in the interface, calling a plurality of file download functions encapsulated in the download interface, so that the plurality of file download functions use the unified context environment to download the file to be downloaded .
根据本发明的又一方面,提供了一种软件开发工具包实现文件下载的装置,所述软件开发工具包应用于云存储系统,所述装置包括:接收模块,用于接收文件下载指令,所述文件下载指令中携带有待下载文件的信息;第二获取模块,用于根据所述文件下载指令和所述待下载文件的信息,从云存储端获取所述待下载文件,并且,获取下载所述待下载文件的统一上下文环境;以及下载模块,用于通过下载接口中设定的应用回调信息类中的成员变量,调用所述下载接口中封装的多个文件下载函数,使所述多个文件下载函数使用所述统一上下文环境进行所述待下载文件的下载。 According to still another aspect of the present invention, a device for downloading a file by a software development kit is provided, the software development kit being applied to a cloud storage system, the device comprising: a receiving module, configured to receive a file download instruction, The file downloading instruction carries the information of the file to be downloaded, and the second obtaining module is configured to obtain the file to be downloaded from the cloud storage end according to the file downloading instruction and the information of the file to be downloaded, and obtain the downloading station. Determining a unified context of the downloaded file; and downloading a module, by using a member variable in the application callback information class set in the download interface, calling a plurality of file download functions encapsulated in the download interface, so that the multiple The file download function performs downloading of the file to be downloaded using the unified context environment.
根据本发明的另一个方面,提供了一种计算机程序,其包括计算机可读代码,当所述计算机可读代码在计算设备上运行时,导致所述计算设备执行上述的软件开发工具包实现文件上传和/或下载的方法。According to another aspect of the present invention, a computer program is provided, comprising computer readable code, when said computer readable code is run on a computing device, causing said computing device to execute said software development kit implementation file Upload and / or download methods.
根据本发明的再一个方面,提供了一种计算机可读介质,其中存储了如上所述的计算机程序。According to still another aspect of the present invention, a computer readable medium storing a computer program as described above is provided.
本申请中,SDK的上传接口和/或下载接口提供了较好的对外合作机制,该上传接口和/或下载接口通过对云存储端上传文件和/或下载文件的方法进行抽象和封装,生成具有应用回调信息类中的成员变量和多个文件上传函数和/或下载函数。在使用该SDK进行文件上传和/或下载时,一次性获取上传待上传文件的统一上下文环境和/或下载待下载文件的统一上下文环境,在该统一上下文环境下,通过上传接口和/或下载接口中的应用回调信息类中的成员变量调用文件上传函数和/或文件下载函数,即可实现相应的文件上传和/或下载,无需开发人员熟悉上传文件和/或下载文件所使用的各个SDK的接口的实现方式和功能,也无需开发人员熟悉上传文件和/或下载文件的各个任务环节和各个任务环节所使用的API接口,从而大幅减少了开发人员的开发难度和提高了开发效率和开发质量,加快了开发速度,降低了开发成本,有效避免了开发缺陷。In this application, the uploading interface and/or downloading interface of the SDK provides a good external cooperation mechanism, and the uploading interface and/or the downloading interface abstracts and encapsulates the method for uploading files and/or downloading files on the cloud storage end to generate Have member variables and multiple file upload functions and/or download functions in the application callback information class. When using the SDK for file uploading and/or downloading, obtain a unified context for uploading the file to be uploaded and/or download a unified context for the file to be downloaded, in the unified context, through the upload interface and/or download The member variables in the application callback information class in the interface call the file upload function and/or the file download function to implement the corresponding file upload and / or download, without the developer familiar with the SDK used to upload files and / or download files. The implementation and functions of the interface do not require developers to be familiar with the various task links of uploading files and/or downloading files and the API interfaces used in each task link, thereby greatly reducing the development difficulty of developers and improving development efficiency and development. Quality, speed up development, reduce development costs, and effectively avoid development defects.
上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。The above description is only an overview of the technical solutions of the present invention, and the above-described and other objects, features and advantages of the present invention can be more clearly understood. Specific embodiments of the invention are set forth below.
附图说明DRAWINGS
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:Various other advantages and benefits will become apparent to those skilled in the art from a The drawings are only for the purpose of illustrating the preferred embodiments and are not to be construed as limiting. Throughout the drawings, the same reference numerals are used to refer to the same parts. In the drawing:
图1是根据本发明实施例一的一种SDK实现文件上传的方法的步骤流程图; 1 is a flow chart showing the steps of a method for implementing file uploading by an SDK according to a first embodiment of the present invention;
图2是根据本发明实施例二的一种SDK实现文件上传的方法的步骤流程图;2 is a flow chart showing the steps of a method for implementing file uploading by an SDK according to Embodiment 2 of the present invention;
图3是根据本发明实施例三的一种SDK实现文件上传的方法的步骤流程图;3 is a flow chart showing the steps of a method for implementing file uploading by an SDK according to Embodiment 3 of the present invention;
图4是根据本发明实施例四的一种SDK实现文件下载的方法的步骤流程图;4 is a flow chart showing the steps of a method for implementing file downloading by an SDK according to Embodiment 4 of the present invention;
图5是根据本发明实施例五的一种SDK实现文件下载的方法的步骤流程图;5 is a flow chart showing the steps of a method for implementing file downloading by an SDK according to Embodiment 5 of the present invention;
图6是根据本发明实施例六的一种SDK实现文件下载的方法的步骤流程图;6 is a flow chart showing the steps of a method for implementing file downloading by an SDK according to Embodiment 6 of the present invention;
图7是根据本发明实施例七的一种SDK实现文件上传的装置的结构框图;7 is a structural block diagram of an apparatus for implementing file uploading by an SDK according to Embodiment 7 of the present invention;
图8是根据本发明实施例八的一种SDK实现文件上传的装置的结构框图;FIG. 8 is a structural block diagram of an apparatus for implementing file uploading by an SDK according to Embodiment 8 of the present invention; FIG.
图9是根据本发明实施例九的一种SDK实现文件下载的装置的结构框图;9 is a structural block diagram of an apparatus for implementing file downloading by an SDK according to Embodiment 9 of the present invention;
图10是根据本发明实施例十的一种SDK实现文件下载的装置的结构框图;FIG. 10 is a structural block diagram of an apparatus for implementing file downloading by an SDK according to Embodiment 10 of the present invention; FIG.
图11示意性地示出了用于执行根据本发明的方法的计算设备的框图;以及Figure 11 schematically shows a block diagram of a computing device for performing the method according to the invention;
图12示意性地示出了用于保持或者携带实现根据本发明的方法的程序代码的存储单元。Fig. 12 schematically shows a storage unit for holding or carrying program code implementing the method according to the invention.
具体实施方式detailed description
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。 Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While the embodiments of the present invention have been shown in the drawings, the embodiments Rather, these embodiments are provided so that this disclosure will be more fully understood and the scope of the disclosure will be fully disclosed.
实施例一Embodiment 1
参照图1,示出了根据本发明实施例一的一种SDK实现文件上传的方法的步骤流程图。Referring to FIG. 1, a flow chart of steps of a method for implementing file uploading by an SDK according to a first embodiment of the present invention is shown.
本实施例的SDK实现文件上传的方法应用于云存储系统,该方法包括以下步骤:The method for implementing file uploading by the SDK in this embodiment is applied to a cloud storage system, and the method includes the following steps:
步骤S102:接收文件上传指令,获取待上传文件的信息及上传待上传文件的统一上下文环境。Step S102: Receive a file upload instruction, obtain information of the file to be uploaded, and upload a unified context of the file to be uploaded.
当有文件需要上传时,上传文件的设备如客户端会向云存储端服务器发送文件上传指令,接收到该指令后,云存储端服务器从相应的设备如客户端获取待上传文件的信息,如待上传文件所在的位置、文件大小、待上传的位置等等有待上传的文件相关的信息。更重要的是,云存储端服务器还会从上传文件的设备中获取上传待上传文件的统一上下文环境。与传统上传文件时,每调用一个函数或接口需要获取一次上下文环境不同,该统一上下文环境仅需一次获取,并在后续该待上传文件的所有上传过程中使用。When a file needs to be uploaded, the device that uploads the file, such as the client, sends a file upload instruction to the cloud storage server. After receiving the instruction, the cloud storage server obtains the information of the file to be uploaded from the corresponding device, such as the client, such as Information about the file to be uploaded, such as the location of the file to be uploaded, the file size, the location to be uploaded, and so on. More importantly, the cloud storage server also obtains a unified context for uploading files to be uploaded from the device that uploads the file. When uploading a file with a traditional one, each call to a function or interface needs to obtain a different context. The unified context needs to be acquired only once, and is used in all subsequent uploading processes of the file to be uploaded.
步骤S104:通过上传接口中设定的应用回调信息类中的成员变量,调用上传接口中封装的多个文件上传函数,使多个文件上传函数根据待上传文件的信息,使用统一上下文环境进行所述待上传的文件的上传。Step S104: Calling a plurality of file uploading functions encapsulated in the uploading interface by uploading the member variables in the application callback information class set in the interface, so that the multiple file uploading functions use the unified context environment according to the information of the file to be uploaded. Report the upload of the uploaded file.
上传接口中的应用回调信息类中的成员变量和多个文件上传函数为对云存储系统的文件上传流程进行分析后确定,可以仅包括实现文件上传功能的基本函数(也即核心函数,基本函数中的任何一个缺少都不能够完成文件上传功能),而其它功能函数则可排除在外,如,文件上传进度显示函数、界面提示函数等等不影响文件上传功能的函数都可排除在外。The member variable and the multiple file upload function in the application callback information class in the upload interface are determined by analyzing the file uploading process of the cloud storage system, and may only include the basic functions (ie, the core function, the basic function) for implementing the file upload function. Any one of the missing ones can not complete the file upload function), while other function functions can be excluded, such as file upload progress display function, interface prompt function and other functions that do not affect the file upload function can be excluded.
应用回调信息类中的成员变量可以将多个文件上传函数按照文件上传任务的执行顺序连接起来,在获取的统一上下文环境中依次执行,实现文件的上传。如上所述,各个文件上传函数在执行时,均使用已获取的统一上下文环境,无需分别逐次获取。The member variables in the callback information class can connect multiple file upload functions according to the execution order of the file upload task, and execute them in the unified context obtained to implement file uploading. As described above, each file upload function uses the acquired unified context environment when it is executed, and does not need to be acquired separately.
通过本实施例,SDK的上传接口提供了较好的对外合作机制,该上传接口通过对云存储端上传文件的方法进行抽象和封装,生成具有应用回调信息 类中的成员变量和多个文件上传函数。在使用该SDK进行文件上传时,一次性获取上传待上传文件的统一上下文环境,在该统一上下文环境下,通过上传接口中的应用回调信息类中的成员变量调用文件上传函数,即可实现文件上传,无需开发人员熟悉上传文件所使用的各个SDK的接口的实现方式和功能,也无需开发人员熟悉上传文件的各个任务环节和各个任务环节所使用的API接口,从而大幅减少了开发人员的开发难度和提高了开发效率和开发质量,加快了开发速度,降低了开发成本,有效避免了开发缺陷。In this embodiment, the upload interface of the SDK provides a good external cooperation mechanism, and the upload interface abstracts and encapsulates the method for uploading files on the cloud storage end to generate the application callback information. Member variables in the class and multiple file upload functions. When using the SDK for file uploading, the unified context for uploading the file to be uploaded is obtained at one time. In the unified context, the file upload function is called by the member variable in the application callback information class in the upload interface, and the file can be implemented. Uploading, no need for developers to be familiar with the implementation and functions of the interfaces of the various SDKs used to upload files, and no need for developers to be familiar with the various task links of uploading files and the API interfaces used in each task link, thus greatly reducing the development of developers. Difficulty and improved development efficiency and development quality, speed up development, reduce development costs, and effectively avoid development defects.
实施例二Embodiment 2
参照图2,示出了根据本发明实施例二的一种SDK实现文件上传的方法的步骤流程图。Referring to FIG. 2, a flow chart of steps of a method for implementing file uploading by an SDK according to a second embodiment of the present invention is shown.
本实施例的SDK实现文件上传的方法应用于云存储系统,该方法包括以下步骤:The method for implementing file uploading by the SDK in this embodiment is applied to a cloud storage system, and the method includes the following steps:
步骤S202:封装SDK的上传接口。Step S202: Encapsulating an upload interface of the SDK.
本实施例中,一种优选的封装SDK上传接口的方式包括:对云存储系统的文件上传流程进行分析,从所有文件上传函数中获取完成文件上传任务的基本函数;将基本函数抽象为应用回调信息类,并根据基本函数定义应用回调信息类中的成员变量;使用成员变量在基本函数间传递参数,并按照文件上传流程确定基本函数的调用顺序;将应用回调信息类和确定了调用顺序的基本函数封装成SDK的上传接口。In this embodiment, a preferred method for packaging an SDK uploading interface includes: analyzing a file uploading process of the cloud storage system, obtaining a basic function of completing a file uploading task from all file uploading functions; abstracting the basic function into an application callback Information class, and according to the basic function definition member variable in the callback information class; use member variables to pass parameters between the basic functions, and determine the calling order of the basic function according to the file upload process; the callback information class is applied and the calling order is determined The basic function is packaged into the upload interface of the SDK.
上述对云存储系统的文件上传流程进行分析,从所有文件上传函数中获取完成文件上传任务的基本函数,以及,将基本函数抽象为应用回调信息类,并根据基本函数定义应用回调信息类中的成员变量的过程在实际操作中,可以由本领域技术人员人工完成,也可以采用成熟的人工智能模型实现,当然,其它可行的适当方式也同样适用。The above analyzes the file uploading process of the cloud storage system, obtains the basic function of completing the file uploading task from all the file uploading functions, and abstracts the basic function into an application callback information class, and defines the application callback information class according to the basic function. The process of the member variable can be manually performed by a person skilled in the art in the actual operation, or can be implemented by a mature artificial intelligence model. Of course, other feasible and appropriate methods are also applicable.
在一个优选实施例中,SDK的上传接口中还封装了上传线程参数,该上传线程参数用于指示上传所述待上传文件时使用的线程数量。通过上传线程参数,可以灵活地对上传文件的线程数量进行设置,提高文件上传的灵活性。In a preferred embodiment, the uploading interface of the SDK further encapsulates an uploading thread parameter, and the uploading thread parameter is used to indicate the number of threads used when uploading the file to be uploaded. By uploading thread parameters, you can flexibly set the number of threads to upload files and improve the flexibility of file uploading.
步骤S204:SDK接收文件上传指令,获取待上传文件的信息及上传所 述待上传文件的统一上下文环境。Step S204: The SDK receives the file uploading instruction, and obtains the information of the file to be uploaded and the uploading station. A unified context for the uploaded file.
该统一上下文环境在本实施例的后续文件上传过程中一直使用。The unified context environment has been used in the subsequent file uploading process of this embodiment.
步骤S206:SDK通过上传接口中设定的应用回调信息类中的成员变量,调用上传接口中封装的多个文件上传函数。Step S206: The SDK calls a plurality of file upload functions encapsulated in the upload interface by uploading member variables in the application callback information class set in the interface.
优选地,当SDK的上传接口中封装有上传线程参数时,在通过上传接口中设定的应用回调信息类中的成员变量,调用上传接口中封装的多个文件上传函数的步骤之前,还包括:接收上传线程参数设置指令,根据上传线程参数设置指令设置的上传线程参数,启动上传线程参数指示数量的上传线程进行待上传的文件的上传。如,上传线程参数设置指令中的上传线程参数指示使用5个线程进行文件上传,则SDK上传接口会启动5个线程接收待上传文件的文件数据块进而进行上传。其中,上传线程参数设置指令可以由上传文件的设备针对每个待上传的文件设置并发送,也可以采用默认的设置值,发送给SDK。Preferably, when the upload thread parameter is encapsulated in the upload interface of the SDK, before the step of calling the multiple file upload functions encapsulated in the upload interface by using the member variable in the application callback information class set in the upload interface, : receiving the upload thread parameter setting instruction, according to the upload thread parameter set by the upload thread parameter setting instruction, starting the uploading thread of the upload thread parameter indicating quantity to upload the file to be uploaded. For example, if the upload thread parameter in the upload thread parameter setting instruction indicates that five threads are used for file uploading, the SDK upload interface starts five threads to receive the file data block of the file to be uploaded and then uploads. The upload thread parameter setting instruction may be set and sent by the device that uploads the file for each file to be uploaded, or may be sent to the SDK by using a default setting value.
在一个优选实施例中,上传接口通过使用设定的应用回调信息类中的成员变量以及句柄参数,调用上传接口中封装的多个文件上传函数;其中,所述句柄参数用于在多个文件上传函数之间传达消息。In a preferred embodiment, the upload interface invokes a plurality of file upload functions encapsulated in the upload interface by using member variables and handle parameters in the set application callback information class; wherein the handle parameters are used in multiple files The message is conveyed between the upload functions.
步骤S208:SDK使用多个文件上传函数根据待上传文件的信息,使用统一上下文环境进行待上传的文件的上传。Step S208: The SDK uses a plurality of file upload functions to upload the file to be uploaded using the unified context environment according to the information of the file to be uploaded.
在本发明的一个优选实施例中,上传接口中还封装有文件秒传函数。当上传接口中封装有文件秒传函数时,在接收文件上传指令,获取待上传文件的信息及上传待上传文件的统一上下文环境的步骤之后,还包括:调用文件秒传函数根据待上传文件的信息,判断待上传文件在云存储端是否已存在;若待上传文件在云存储端已存在,则建立用户的用户标识与已存在的文件之间的链接;若不存在,则执行步骤S206。In a preferred embodiment of the invention, the file interface is also encapsulated with a file second pass function. After the file upload function is encapsulated in the upload interface, after receiving the file upload instruction, obtaining the information of the file to be uploaded, and uploading the unified context of the file to be uploaded, the method further includes: calling the file second pass function according to the file to be uploaded. If the file to be uploaded exists on the cloud storage end, the link between the user identifier of the user and the existing file is established; if not, the step S206 is performed.
通过本实施例,在使用SDK进行文件上传时,一次性获取上传待上传文件的统一上下文环境,在该统一上下文环境下,通过上传接口中的应用回调信息类中的成员变量调用文件上传函数,即可实现文件上传,无需开发人员熟悉上传文件所使用的各个SDK的接口的实现方式和功能,也无需开发 人员熟悉上传文件的各个任务环节和各个任务环节所使用的API接口,从而大幅减少了开发人员的开发难度和提高了开发效率和开发质量,加快了开发速度,降低了开发成本,有效避免了开发缺陷。In this embodiment, when the file is uploaded by using the SDK, the unified context of uploading the file to be uploaded is obtained at one time, and in the unified context, the file upload function is called by the member variable in the application callback information class in the upload interface. File upload is possible, no need for developers to be familiar with the implementation and functions of the interfaces of the various SDKs used to upload files, and no need to develop The personnel are familiar with the various task links of the uploaded files and the API interfaces used in each task link, thereby greatly reducing the development difficulty of the developer and improving the development efficiency and development quality, speeding up the development, reducing the development cost, and effectively avoiding the development. defect.
实施例三Embodiment 3
本实施例以具体实例对本发明的SDK实现文件上传的方法进行说明,该方法应用于云存储系统。This embodiment describes a method for uploading a file implementation of the SDK of the present invention by using a specific example, and the method is applied to a cloud storage system.
本实施例的SDK实现文件上传的方法包括以下步骤:The method for implementing file uploading by the SDK of this embodiment includes the following steps:
步骤一:生成SDK的上传接口。Step 1: Generate an upload interface for the SDK.
以下,从多个方面对生成SDK的上传接口的过程进行说明。Hereinafter, the process of generating an upload interface of the SDK will be described from various aspects.
(一)软件环境需求:(1) Software environment requirements:
a、开发环境:android2.1及2.1以上;a, development environment: android2.1 and above 2.1;
b、需要的权限:至少包括生成SDK所需要进行的访问的权限,以android应用的权限配置为例,如:b. Required permissions: At least the permissions required to generate the SDK, such as the permission configuration of the android application, such as:
Figure PCTCN2014089765-appb-000001
Figure PCTCN2014089765-appb-000001
c、必要条件c, necessary conditions
(1)、设置Application(应用)对象,通过获取应用的Application对象,可以让SDK得到当前应用的上下文环境,如当前上传的文件的统一上下文环境。Application对象是android框架的一个系统组件,当android程序启动时系统会创建一个application对象,用来存储系统的一些信息。android系统会为每个程序运行时创建一个Application类的对象且仅创建一个,所以Application可以说是单例(singleton)模式的一个类,且Application对象的生 命周期是整个程序中最长的,它的生命周期就等于这个程序的生命周期。因为它是全局的单例的,所以通过Application对象来进行一些数据传递、数据共享、数据缓存等操作。(1), set the Application object, by obtaining the Application object of the application, the SDK can get the context of the current application, such as the unified context of the currently uploaded file. The Application object is a system component of the android framework. When the android program starts, the system creates an application object to store some information about the system. Android system will create an Application class object for each program runtime and only create one, so Application can be said to be a singleton (singleton) mode of a class, and the Application object's health The life cycle is the longest in the entire program, and its life cycle is equal to the life cycle of the program. Because it is a global singleton, so through the Application object for some data transfer, data sharing, data cache and other operations.
如:设置Such as: setting
com.qihoo.yunpan.sdk.android.config.YunpanApplication.setApplication()方法;com.qihoo.yunpan.sdk.android.config.YunpanApplication.setApplication() method;
或者,设置Or, set
<application android:name=<application android:name=
″com.qihoo.yunpan.sdk.android.config.YunpanApplication″.../>中的一个。One of "com.qihoo.yunpan.sdk.android.config.YunpanApplication".../>.
(2)、设置开发权限(2), set development permissions
如,key(AUTH_NAME,AUTH_KEY,AUTH_SECRET)必须赋值给com.qihoo.yunpan.sdk.android.config.YunpanSDKConstants中对应的值。For example, key(AUTH_NAME, AUTH_KEY, AUTH_SECRET) must be assigned to the corresponding value in com.qihoo.yunpan.sdk.android.config.YunpanSDKConstants.
(3)、必须实现(3) must be achieved
com.qihoo.yunpan.sdk.android.config.YunpanSDKConstants.setYunpanInter face(IYunpanInterface yunpanInterface)接口,以保证实现文件上传任务的安全性。The com.qihoo.yunpan.sdk.android.config.YunpanSDKConstants.setYunpanInter face(IYunpanInterface yunpanInterface) interface ensures the security of the file upload task.
通过该接口实现onNewUserToken函数和onUserCookieInvalid函数,其中,onNewUserToken函数用于刷新用户token,onUserCookieInvalid用于当用户cookie失效时,要求用户必须重新登陆。The onNewUserToken function and the onUserCookieInvalid function are implemented through the interface, wherein the onNewUserToken function is used to refresh the user token, and the onUserCookieInvalid is used to require the user to re-login when the user cookie fails.
(二)(two)
对云存储系统的文件上传流程进行分析,从所有文件上传函数中获取完成文件上传任务的基本函数;将基本函数抽象为应用回调信息类,并根据基本函数定义应用回调信息类中的成员变量;使用成员变量在基本函数间传递参数,并按照文件上传流程确定基本函数的调用顺序;将应用回调信息类和确定了调用顺序的基本函数封装成SDK的上传接口。例如,云存储系统在进行文件上传时,由客户端发送文件上传指令,上传文件;而云存储端服务器接收到文件上传指令后,得知有文件上传任务,开始获取文件数据块,进 而根据文件上传指令将获取到的文件数据块存储至指定位置。对该流程进行分析后,确定对于SDK来说,获取上传文件的相关数据(包括文件名、大小、位置、文件上下文环境、文件数据等)对应的各个函数,以及根据上传文件相关数据将文件存储到指定位置对应的各个函数均可被认为是基本函数,对这些基本函数进行抽象和封装,最终生成SDK的上传接口。Analyze the file uploading process of the cloud storage system, obtain the basic function of completing the file uploading task from all the file uploading functions; abstract the basic function into the application callback information class, and define the member variables in the application callback information class according to the basic function; The member variable is used to pass parameters between the basic functions, and the calling sequence of the basic function is determined according to the file uploading process; the application callback information class and the basic function that determines the calling sequence are encapsulated into an SDK uploading interface. For example, when the cloud storage system uploads a file, the client sends a file upload instruction to upload the file; and after receiving the file upload instruction, the cloud storage server learns that there is a file upload task, and starts to obtain the file data block. The obtained file data block is stored to the specified location according to the file upload instruction. After analyzing the process, it is determined that for the SDK, each function corresponding to the uploaded data (including file name, size, location, file context, file data, etc.) is acquired, and the file is stored according to the data related to the uploaded file. Each function corresponding to the specified position can be regarded as a basic function, abstracting and encapsulating these basic functions, and finally generating an upload interface of the SDK.
(1)抽象成的统一的应用回调信息类为:(1) The abstracted application callback information class is:
Class com.qihoo.yunpan.sdk.android.task.TransferStatus;其包括的成员变量有:Class com.qihoo.yunpan.sdk.android.task.TransferStatus; its included member variables are:
名称:actionTypeName: actionType
类型:ActionType,描述:当前传送状态Type: ActionType, Description: Current delivery status
名称:localFileNameName: localFileName
类型:String,描述:本地文件名Type: String, Description: Local file name
名称:remoteFileNameName: remoteFileName
类型:String,描述:云存储端文件名Type: String, Description: Cloud storage file name
名称:requestCodeName: requestCode
类型:String,描述:请求code(应用自行控制)Type: String, Description: Request code (application control)
其中,ActionType(消息类型枚举)为com.qihoo.yunpan.sdk.android.task.TransferStatus.ActionType,其值包括:The ActionType (message type enumeration) is com.qihoo.yunpan.sdk.android.task.TransferStatus.ActionType, and its values include:
名称:NULLName: NULL
描述:无意义Description: meaningless
名称:UPLOAD_PROCESSINGName: UPLOAD_PROCESSING
描述:上传任务处理中 Description: Upload task processing
名称:UPLOAD_FILE_HASHName: UPLOAD_FILE_HASH
描述:计算上传文件shalDescription: Calculate the upload file shal
名称:UPLOAD_TRANSFER_DATAName: UPLOAD_TRANSFER_DATA
描述:上传任务中正在上传数据Description: Uploading data in the upload task
名称:UPLOAD_COMPLETEName: UPLOAD_COMPLETE
描述:上传任务完成Description: Upload task completed
(2)构造文件上传函数,实现文件上传任务(2) Construct a file upload function to implement a file upload task
如,生成Class com.qihoo.yunpan.sdk.android.task.UploadTaskFor example, generate Class com.qihoo.yunpan.sdk.android.task.UploadTask
构造函数:UploadTask()Constructor: UploadTask()
参数1:(名称:localFileName,类型:String,描述:本地文件名)Parameter 1: (name: localFileName, type: String, description: local file name)
参数2:(名称:remoteFileName,类型:String,描述:云存储端文件名)Parameter 2: (name: remoteFileName, type: String, description: cloud storage file name)
参数3:(名称:upload_handler,类型:Handler,描述:传达消息)Parameter 3: (name: upload_handler, type: Handler, description: convey message)
实现上述应用回调信息类和上传函数后,即可封装为上传接口向外提供。After the application callback information class and the upload function are implemented, the package can be encapsulated as an upload interface.
优选地,在上传接口中还可以设置上传进度步长:(默认为5%触发一次,最小1,最大20),可以通过调用setProgressStep()和getProgressStep()方法设置返回数据集的位置。Preferably, the upload progress step size can also be set in the upload interface: (default is 5% trigger once, minimum 1 and maximum 20), and the position of the returned data set can be set by calling setProgressStep() and getProgressStep().
优选地,在上传接口中还可以设置停止当前任务:(如果重新开始,请将当前任务重新在线程容器中启动),可以通过调用setIsRun(false)停止当前任务。Preferably, the current task can also be set in the upload interface: (If restarting, restart the current task in the thread container), the current task can be stopped by calling setIsRun(false).
优选地,在上传接口中还可以设置单任务运行时的线程数:(默认为1,最大5),可以通过调用setUploadThreadNum(上传任务线程数)设置。通过设置线程数,实现SDK封装的上传任务支持JAVA标准的多线程环境。Preferably, the number of threads in a single task runtime can also be set in the upload interface: (default is 1, maximum 5), which can be set by calling setUploadThreadNum (upload task thread). By setting the number of threads, the SDK package upload task supports the JAVA standard multi-threaded environment.
其它主要云盘SDK方法还包括:Other major cloud disk SDK methods also include:
a、用户注册(UserIntfRegister) a, user registration (UserIntfRegister)
生成Class com.qihoo.yunpan.sdk.android.http.action.UserIntfRegisterGenerate Class com.qihoo.yunpan.sdk.android.http.action.UserIntfRegister
构造函数如下:The constructor is as follows:
函数名:doUserIntfRegister()Function name: doUserIntfRegister()
参数1:(名称:userName,类型:String,描述:用户名)Parameter 1: (name: userName, type: String, description: username)
参数2:(名称:passWord,类型:String,描述:密码)Parameter 2: (name: passWord, type: String, description: password)
(如果调用完获取验证码接口后,请将sc参数通过setSc()传入,setCaptcha()方法传入用户输入的验证码)(If you call the get verification code interface, please pass the sc parameter via setSc(), and the setCaptcha() method will pass the verification code entered by the user)
返回类型:UserCenterInfoReturn type: UserCenterInfo
(如果返回值中的errno=5010,需要调用方法获取验证码(UserIntfGetCaptcha)获取)(If the errno=5010 in the return value, you need to call the method to get the verification code (UserIntfGetCaptcha) to get)
b、用户登录(UserIntfLogin)b, user login (UserIntfLogin)
生成Class com.qihoo.yunpan.sdk.android.http.action.UserIntfLoginGenerate Class com.qihoo.yunpan.sdk.android.http.action.UserIntfLogin
构造函数如下:The constructor is as follows:
函数名:login()Function name: login()
参数1:(名称:username,类型:String,描述:用户名)Parameter 1: (name: username, type: String, description: username)
参数2:(名称:passWord,类型:String,描述:密码)Parameter 2: (name: passWord, type: String, description: password)
参数3:(名称:captcha,类型:String,描述:用户输入的验证码)Parameter 3: (name: captcha, type: String, description: the verification code entered by the user)
参数4:(名称:sc,类型:String,描述:服务器返回的sc参数)Parameter 4: (name: sc, type: String, description: sc parameter returned by the server)
(如果调用完获取验证码接口后,请将captcha和sc参数赋值,没有验证码时给空值)(If you call the get verification code interface, please assign the captcha and sc parameters, and leave a null value when there is no verification code)
返回类型:UserCenterInfoReturn type: UserCenterInfo
(如果返回值中的errno=5010,需要调用方法获取验证码(UserIntfGetCaptcha)获取)(If the errno=5010 in the return value, you need to call the method to get the verification code (UserIntfGetCaptcha) to get)
c、获取云盘列表(FileGetNodeList)c, get the cloud disk list (FileGetNodeList)
生成Class com.qihoo.yunpan.sdk.android.http.action.getNodeListGenerate Class com.qihoo.yunpan.sdk.android.http.action.getNodeList
构造函数如下:The constructor is as follows:
函数名:getNodeList()Function name: getNodeList()
参数:(名称:path,类型:String,描述:云盘目录,/为根目录) Parameters: (name: path, type: String, description: cloud disk directory, / is the root directory)
返回类型:FileNodeListReturn type: FileNodeList
分页功能:(两项同时设置才生效,默认为从0开始全部)Pagination function: (Two simultaneous settings take effect, the default is all from 0)
包括:通过调用setStart()和getStart()方法设置返回数据集的位置,通过调用setCount()和getCount()方法设置返回数据集的数量;实现排序功能:通过调用setOrderParam()和getOrderParam()方法设置排序字段(默认为按文件名排序),通过调用setIsdesc()和isIsdesc()方法设置正序或倒序(默认为正序);设置内部类This includes setting the position of the returned dataset by calling the setStart() and getStart() methods, and setting the number of returned datasets by calling the setCount() and getCount() methods; implementing the sorting function: by calling the setOrderParam() and getOrderParam() methods Set the sort field (the default is to sort by file name), set the positive or reverse order by calling setIsdesc() and isIsdesc() (the default is positive); set the inner class
enum com.qihoo.yunpan.sdk.android.http.action.getNodeList.OrderTypeEnum com.qihoo.yunpan.sdk.android.http.action.getNodeList.OrderType
该内部类枚举类型的值包括:The values of this inner class enumeration type include:
名称:nameName: name
描述:按文件名Description: by file name
名称:mtimeName: mtime
描述:按修改时间Description: By modification time
名称:fsizeName: fsize
描述:按文件大小Description: by file size
d、获取文件分享链接(LinkCreateFile)d, get the file share link (LinkCreateFile)
生成Class com.qihoo.yunpan.sdk.android.http.action.LinkCreateFileGenerate Class com.qihoo.yunpan.sdk.android.http.action.LinkCreateFile
构造函数如下:The constructor is as follows:
函数名:getFileLink()Function name: getFileLink()
参数:(名称:nameList,类型:List<String>,描述:需要生成连接的文件或文件夹列表)Parameters: (name: nameList, type: List<String>, description: list of files or folders that need to generate a connection)
返回类型:LinkCreateFileDataReturn type: LinkCreateFileData
通过上述函数,实现了SDK上传任务的秒传。Through the above functions, the second transmission of the SDK upload task is realized.
上述其它主要云盘SDK方法中的一种或多种均可以可选方式封装入上传接口中,以为用户上传文件提供更好的使用体验。 One or more of the other major cloud disk SDK methods may be encapsulated into the upload interface in an optional manner to provide a better user experience for uploading files.
步骤二:使用生成的SDK上传接口上传文件。Step 2: Upload the file using the generated SDK upload interface.
一种使用步骤一中生成的上传接口上传文件的流程如图3所示,该流程包括:A process for uploading a file using the upload interface generated in step one is as shown in FIG. 3, and the process includes:
步骤S302:接收文件上传指令,上传任务开始。Step S302: Receive a file upload instruction, and the upload task starts.
步骤S304:SDK上传接口中的文件上传函数计算待上传文件的hash(哈希)值。Step S304: The file upload function in the SDK upload interface calculates a hash value of the file to be uploaded.
步骤S306:SDK上传接口中的文件上传函数申请文件上传任务。Step S306: The file upload function application file upload task in the SDK upload interface.
步骤S308:SDK上传接口中的文件上传函数判断待上传的文件数据是否已存在,若否,则执行步骤S310;若是,则执行步骤S318。Step S308: The file upload function in the SDK uploading interface determines whether the file data to be uploaded already exists. If not, step S310 is performed; if yes, step S318 is performed.
步骤S310:SDK上传接口中的文件上传函数获取待上传的文件的文件块信息。Step S310: The file upload function in the SDK upload interface acquires file block information of the file to be uploaded.
步骤S312:SDK上传接口中的文件上传函数判断是否完成文件上传,若是,则执行步骤S314;若否,则本次文件上传失败。Step S312: The file upload function in the SDK uploading interface determines whether the file upload is completed. If yes, step S314 is performed; if not, the file upload fails.
步骤S314:SDK上传接口中的文件上传函数确认待上传文件的文件数据全部上传完毕,执行步骤S318。Step S314: The file upload function in the SDK uploading interface confirms that all the file data of the file to be uploaded is completely uploaded, and step S318 is performed.
步骤S316:SDK上传接口中的文件上传函数确认本次上传任务完成。Step S316: The file upload function in the SDK upload interface confirms that the upload task is completed.
步骤S318:SDK上传接口中的文件上传函数提示上传完成。Step S318: The file upload function in the SDK upload interface prompts that the upload is completed.
通过本实施例,实现了在android系统的移动终端上,通过SDK实现文件上传的任务,大幅减少了移动终端开发人员的开发难度和提高了移动终端开发效率和开发质量,加快了开发速度,降低了开发成本,有效避免了开发缺陷。Through the embodiment, the task of uploading files through the SDK is realized on the mobile terminal of the android system, the development difficulty of the mobile terminal developer is greatly reduced, the development efficiency and development quality of the mobile terminal are improved, the development speed is accelerated, and the development speed is lowered. The development cost effectively avoids development defects.
实施例四Embodiment 4
参照图4,示出了根据本发明实施例四的一种SDK实现文件下载的方法的步骤流程图。Referring to FIG. 4, a flow chart of steps of a method for implementing file downloading by an SDK according to Embodiment 4 of the present invention is shown.
本实施例的SDK实现文件下载的方法应用于云存储系统,该方法包括以下步骤:The method for implementing file downloading by the SDK in this embodiment is applied to a cloud storage system, and the method includes the following steps:
步骤S402:接收文件下载指令。Step S402: Receive a file download instruction.
其中,该文件下载指令中携带有待下载文件的信息。 The file download instruction carries information about the file to be downloaded.
当客户端需要下载文件时,会向云存储端服务器发送文件下载指令,该指令中携带有待下载文件的相关信息,如待下载文件所在的位置、文件大小、待存储的位置等等信息。云存储端服务器从文件下载指令中获取这些待下载文件的信息。When the client needs to download the file, it sends a file download command to the cloud storage server, where the command carries information about the file to be downloaded, such as the location of the file to be downloaded, the file size, the location to be stored, and the like. The cloud storage server obtains the information of the files to be downloaded from the file download instruction.
步骤S404:根据文件下载指令和待下载文件的信息,从云存储端获取待下载文件,并且,获取下载待下载文件的统一上下文环境。Step S404: Obtain a file to be downloaded from the cloud storage end according to the file download instruction and the information of the file to be downloaded, and obtain a unified context for downloading the file to be downloaded.
云存储系统包括客户端和云端,云端包括至少一台用于存储数据的服务器,本发明实施例中简称为云存储端,该云存储端存储有待下载的文件。The cloud storage system includes a client and a cloud, and the cloud includes at least one server for storing data. In the embodiment of the present invention, it is simply referred to as a cloud storage terminal, and the cloud storage terminal stores files to be downloaded.
其中,与传统下载文件时,每调用一个函数或接口需要获取一次上下文环境不同,本发明中,云存储端服务器在获取待下载文件时,获取下载待下载文件的统一上下文环境,该统一上下文环境仅需一次获取,并在后续该待下载文件的所有下载过程中使用。In the present invention, the cloud storage server obtains a unified context environment for downloading the file to be downloaded when the file to be downloaded is obtained, and the unified context is obtained. It only needs to be obtained once and used in all subsequent downloads of the file to be downloaded.
步骤S406:通过下载接口中设定的应用回调信息类中的成员变量,调用下载接口中封装的多个文件下载函数,使多个文件下载函数使用统一上下文环境进行待下载文件的下载。Step S406: Calling a plurality of file download functions encapsulated in the download interface by using a member variable in the application callback information class set in the download interface, so that the plurality of file download functions use the unified context environment to download the file to be downloaded.
下载接口中的应用回调信息类中的成员变量和多个文件下载函数为对云存储系统的文件下载流程进行分析后确定,可以仅包括实现文件下载功能的基本函数(也即核心函数,基本函数中的任何一个缺少都不能够完成文件下载功能),如,获取下载文件的相关数据(包括文件名、大小、位置、文件上下文环境、文件数据等)对应的各个函数,以及根据下载文件相关数据将文件下载至指定位置对应的各个函数;而其它功能函数则可排除在外,如,文件下载进度显示函数、界面提示函数等等不影响文件下载功能的函数都可排除在外。The member variable and the multiple file download function in the application callback information class in the download interface are determined by analyzing the file downloading process of the cloud storage system, and may only include the basic functions (ie, the core function, the basic function) for implementing the file download function. The lack of any of the files can not complete the file download function), for example, to obtain the corresponding data of the downloaded file (including file name, size, location, file context, file data, etc.) and the data according to the downloaded file. Download the file to each function corresponding to the specified location; other functions can be excluded, such as file download progress display function, interface prompt function, etc. Functions that do not affect the file download function can be excluded.
应用回调信息类中的成员变量可以将多个文件下载函数按照文件下载任务的执行顺序连接起来,在获取的统一上下文环境中依次执行,实现文件的下载。如上所述,各个文件下载函数在执行时,均使用已获取的统一上下文环境,无需分别逐次获取。The member variables in the application callback information class can connect multiple file download functions according to the execution order of the file download task, execute sequentially in the acquired unified context environment, and implement file download. As described above, each file download function uses the acquired unified context environment when it is executed, and does not need to be acquired sequentially.
通过本实施例,SDK的下载接口提供了较好的对外合作机制,该下载接 口通过对云存储端下载文件的方法进行抽象和封装,生成具有应用回调信息类中的成员变量和多个文件下载函数。在使用该SDK进行文件下载时,一次性获取下载待下载文件的统一上下文环境,在该统一上下文环境下,通过下载接口中的应用回调信息类中的成员变量调用文件下载函数,即可实现文件下载,无需开发人员熟悉下载文件所使用的各个SDK的接口的实现方式和功能,也无需开发人员熟悉下载文件的各个任务环节和各个任务环节所使用的API接口,从而大幅减少了开发人员的开发难度和提高了开发效率和开发质量,加快了开发速度,降低了开发成本,有效避免了开发缺陷。Through this embodiment, the download interface of the SDK provides a better external cooperation mechanism, and the download interface The port abstracts and encapsulates the method of downloading files from the cloud storage terminal, and generates a member variable and a plurality of file download functions in the application callback information class. When the file is downloaded by using the SDK, the unified context for downloading the file to be downloaded is obtained at one time. In the unified context, the file download function is called by the member variable in the application callback information class in the download interface, and the file can be implemented. Download, no need for developers to be familiar with the implementation and function of the interface of each SDK used to download files, and no need for developers to be familiar with the various task links of downloading files and API interfaces used in each task link, thus greatly reducing developer development. Difficulty and improved development efficiency and development quality, speed up development, reduce development costs, and effectively avoid development defects.
实施例五Embodiment 5
参照图5,示出了根据本发明实施例五的一种SDK实现文件下载的方法的步骤流程图。Referring to FIG. 5, a flow chart of steps of a method for implementing file downloading by an SDK according to Embodiment 5 of the present invention is shown.
本实施例的SDK实现文件下载的方法应用于云存储系统,该方法包括以下步骤:The method for implementing file downloading by the SDK in this embodiment is applied to a cloud storage system, and the method includes the following steps:
步骤S502:封装SDK的下载接口。Step S502: Encapsulating the download interface of the SDK.
本实施例中,一种优选的封装SDK下载接口的方式包括:对云存储系统的文件下载流程进行分析,从所有文件下载函数中获取完成文件下载任务的基本函数;将基本函数抽象为应用回调信息类,并根据基本函数定义应用回调信息类中的成员变量;使用成员变量在基本函数间传递参数,并按照文件下载流程确定基本函数的调用顺序;将应用回调信息类和确定了调用顺序的基本函数封装成SDK的下载接口。In this embodiment, a preferred method for packaging the SDK download interface includes: analyzing a file downloading process of the cloud storage system, obtaining a basic function of completing a file download task from all file download functions; abstracting the basic function into an application callback Information class, and according to the basic function definition member variable in the callback information class; use member variables to pass parameters between the basic functions, and determine the calling order of the basic function according to the file download process; the callback information class is applied and the calling order is determined The basic function is packaged into the download interface of the SDK.
上述对云存储系统的文件下载流程进行分析,从所有文件下载函数中获取完成文件下载任务的基本函数,以及,将基本函数抽象为应用回调信息类,并根据基本函数定义应用回调信息类中的成员变量的过程在实际操作中,可以由本领域技术人员人工完成,也可以采用成熟的人工智能模型实现,当然,其它可行的适当方式也同样适用。The above analyzes the file downloading process of the cloud storage system, obtains the basic function of completing the file download task from all file download functions, and abstracts the basic function into an application callback information class, and defines the application callback information class according to the basic function. The process of the member variable can be manually performed by a person skilled in the art in the actual operation, or can be implemented by a mature artificial intelligence model. Of course, other feasible and appropriate methods are also applicable.
在一个优选实施例中,SDK的下载接口中还封装了下载线程参数,该下载线程参数用于指示下载所述待下载文件时使用的线程数量。通过下载线程参数,可以灵活地对下载文件的线程数量进行设置,提高文件下载的灵活性。 In a preferred embodiment, the download interface of the SDK further encapsulates a download thread parameter, and the download thread parameter is used to indicate the number of threads used when downloading the file to be downloaded. By downloading the thread parameters, you can flexibly set the number of threads for downloading files, improving the flexibility of file downloading.
步骤S504:SDK接收文件下载指令,该文件下载指令中携带有待下载文件的信息。Step S504: The SDK receives a file download instruction, where the file download instruction carries information of the file to be downloaded.
步骤S506:SDK根据文件下载指令和待下载文件的信息,从云存储端获取待下载文件,并且,获取下载所述待下载文件的统一上下文环境。Step S506: The SDK obtains the file to be downloaded from the cloud storage end according to the file download instruction and the information of the file to be downloaded, and obtains a unified context environment for downloading the file to be downloaded.
该统一上下文环境在本实施例的后续文件下载过程中一直使用。This unified context environment has been used throughout the subsequent file downloading process of this embodiment.
优选地,当SDK的下载接口中封装有下载线程参数时,在SDK根据文件下载指令和待下载文件的信息,从云存储端获取待下载文件,并且,获取下载所述待下载文件的统一上下文环境的步骤之前,还包括:接收下载线程参数设置指令,根据下载线程参数设置指令设置的下载线程参数,启动下载线程参数指示数量的下载线程进行待下载的文件的下载。如,下载线程参数设置指令中的下载线程参数指示使用5个线程进行文件下载,则SDK下载接口会启动5个线程从云存储端获取待下载文件的文件数据块,进而进行文件下载。其中,下载线程参数设置指令可以由下载文件的设备针对每个待下载的文件设置并发送,也可以采用默认的设置值,发送给SDK。Preferably, when the download thread parameter is encapsulated in the download interface of the SDK, the SDK obtains the file to be downloaded from the cloud storage terminal according to the file download instruction and the information of the file to be downloaded, and obtains a unified context for downloading the file to be downloaded. Before the step of the environment, the method further includes: receiving a download thread parameter setting instruction, and starting a download thread of the number of indications of the download thread parameter to download the file to be downloaded according to the download thread parameter set by the download thread parameter setting instruction. For example, if the download thread parameter in the download thread parameter setting instruction indicates that the file is downloaded using 5 threads, the SDK download interface starts 5 threads to obtain the file data block of the file to be downloaded from the cloud storage end, and then downloads the file. The download thread parameter setting instruction may be set and sent by the device that downloads the file for each file to be downloaded, or may be sent to the SDK by using a default setting value.
步骤S508:SDK通过下载接口中设定的应用回调信息类中的成员变量,调用下载接口中封装的多个文件下载函数。Step S508: The SDK calls a plurality of file download functions encapsulated in the download interface by downloading member variables in the application callback information class set in the interface.
在一个可选实施例中,下载接口通过使用设定的应用回调信息类中的成员变量以及句柄参数,调用下载接口中封装的多个文件下载函数;其中,所述句柄参数用于在多个文件下载函数之间传达消息。In an optional embodiment, the download interface invokes a plurality of file download functions encapsulated in the download interface by using a member variable and a handle parameter in the set application callback information class; wherein the handle parameter is used in multiple Messages are sent between file download functions.
步骤S510:SDK使用多个文件下载函数使用统一上下文环境进行待下载文件的下载。Step S510: The SDK uses a plurality of file download functions to download the file to be downloaded using the unified context.
在本发明的一个可选实施例中,下载接口中还封装有下载历史记录函数。当下载接口中封装有下载历史记录函数时,在SDK接收文件下载指令的步骤之后,还包括:使用下载接口中的应用回调信息类中的成员变量,调用下载接口中封装的下载历史记录函数,通过下载历史记录函数判断发送文件下载指令的客户端是否已下载过待下载文件;若已下载过,则判断客户端中已下载的待下载文件是否有效;若有效,则结束待下载文件的下载;若无效或者若未下载过待下载文件,则执行步骤S506。通过下载历史记录函数, 可以有效避免文件的重复下载。In an optional embodiment of the invention, the download interface is also encapsulated with a download history function. When the download history function is encapsulated in the download interface, after the step of receiving the file download instruction by the SDK, the method further includes: calling the download history function encapsulated in the download interface by using a member variable in the application callback information class in the download interface, The download history function determines whether the client that sent the file download instruction has downloaded the file to be downloaded; if it has been downloaded, it determines whether the downloaded file to be downloaded in the client is valid; if it is valid, the download of the file to be downloaded is ended. If it is invalid or if the file to be downloaded has not been downloaded, step S506 is performed. By downloading the history function, Can effectively avoid repeated downloads of files.
通过本实施例,在使用SDK进行文件下载时,一次性获取下载待下载文件的统一上下文环境,在该统一上下文环境下,通过下载接口中的应用回调信息类中的成员变量调用文件下载函数,即可实现文件下载,无需开发人员熟悉下载文件所使用的各个SDK的接口的实现方式和功能,也无需开发人员熟悉下载文件的各个任务环节和各个任务环节所使用的API接口,从而大幅减少了开发人员的开发难度和提高了开发效率和开发质量,加快了开发速度,降低了开发成本,有效避免了开发缺陷。In this embodiment, when the file is downloaded by using the SDK, the unified context for downloading the file to be downloaded is obtained at one time, and in the unified context, the file download function is invoked by using the member variable in the application callback information class in the download interface. File download can be realized, no need for developers to be familiar with the implementation and functions of the interfaces of each SDK used to download files, and no need for developers to be familiar with the various task links of downloading files and the API interfaces used in each task link, thus greatly reducing the number of The development difficulty of developers and the improvement of development efficiency and development quality, speed up development, reduce development costs, and effectively avoid development defects.
实施例六Embodiment 6
本实施例以具体实例对本发明的SDK实现文件下载的方法进行说明,该方法应用于云存储系统。This embodiment describes a method for downloading the SDK implementation file of the present invention by using a specific example, and the method is applied to a cloud storage system.
本实施例的SDK实现文件下载的方法包括以下步骤:The method for implementing the file downloading by the SDK of this embodiment includes the following steps:
步骤一:生成SDK的下载接口。Step 1: Generate the download interface of the SDK.
以下,从多个方面对生成SDK的下载接口的过程进行说明。Hereinafter, the process of generating the download interface of the SDK will be described from various aspects.
(一)软件环境需求:(1) Software environment requirements:
a、开发环境:android2.1及2.1以上;a, development environment: android2.1 and above 2.1;
b、需要的权限:至少包括生成SDK所需要进行的访问的权限,以android应用的权限配置为例,如:b. Required permissions: At least the permissions required to generate the SDK, such as the permission configuration of the android application, such as:
Figure PCTCN2014089765-appb-000002
Figure PCTCN2014089765-appb-000002
c、必要条件c, necessary conditions
(1)、设置Application(应用)对象,通过获取应用的Application对象, 可以让SDK得到当前应用的上下文环境,如当前下载的文件的统一上下文环境。Application对象是android框架的一个系统组件,当android程序启动时系统会创建一个application对象,用来存储系统的一些信息。android系统会为每个程序运行时创建一个Application类的对象且仅创建一个,所以Application可以说是单例(singleton)模式的一个类,且Application对象的生命周期是整个程序中最长的,它的生命周期就等于这个程序的生命周期。因为它是全局的单例的,所以通过Application对象来进行一些数据传递、数据共享、数据缓存等操作。(1), set the Application object, by obtaining the application object of the application, You can let the SDK get the context of the current application, such as the unified context of the currently downloaded file. The Application object is a system component of the android framework. When the android program starts, the system creates an application object to store some information about the system. Android system will create an Application class object for each program runtime and only create one, so Application can be said to be a singleton (singleton) pattern of a class, and the Application object's life cycle is the longest in the entire program, it The life cycle is equal to the life cycle of this program. Because it is a global singleton, so through the Application object for some data transfer, data sharing, data cache and other operations.
如:设置Such as: setting
com.qihoo.yunpan.sdk.android.config.YunpanApplication.setApplication()方法;com.qihoo.yunpan.sdk.android.config.YunpanApplication.setApplication() method;
或者,设置Or, set
<application android:name=<application android:name=
″com.qihoo.yunpan.sdk.android.config.YunpanApplication″.../>中的一个。One of "com.qihoo.yunpan.sdk.android.config.YunpanApplication".../>.
(2)、设置开发权限(2), set development permissions
如,key(AUTH_NAME,AUTH_KEY,AUTH_SECRET)必须赋值给com.qihoo.yunpan.sdk.android.config.YunpanSDKConstants中对应的值。For example, key(AUTH_NAME, AUTH_KEY, AUTH_SECRET) must be assigned to the corresponding value in com.qihoo.yunpan.sdk.android.config.YunpanSDKConstants.
(3)、必须实现(3) must be achieved
com.qihoo.yunpan.sdk.android.config.YunpanSDKConstants.setYunpanInter face(IYunpanInterface yunpanInterface)接口,以保证实现文件下载任务的安全性。The com.qihoo.yunpan.sdk.android.config.YunpanSDKConstants.setYunpanInterface(IYunpanInterface yunpanInterface) interface ensures the security of the file download task.
通过该接口实现onNewUserToken函数和onUserCookieInvalid函数,其中,onNewUserToken函数用于刷新用户token,onUserCookieInvalid用于当用户cookie失效时,要求用户必须重新登陆。The onNewUserToken function and the onUserCookieInvalid function are implemented through the interface, wherein the onNewUserToken function is used to refresh the user token, and the onUserCookieInvalid is used to require the user to re-login when the user cookie fails.
(二)(two)
对云存储系统的文件下载流程进行分析,从所有文件下载函数中获取完成文件下载任务的基本函数;将基本函数抽象为应用回调信息类,并根据基 本函数定义应用回调信息类中的成员变量;使用成员变量在基本函数间传递参数,并按照文件下载流程确定基本函数的调用顺序;将应用回调信息类和确定了调用顺序的基本函数封装成SDK的下载接口。例如,云存储系统在进行文件下载时,由客户端发送文件下载指令,而云存储端服务器接收到文件下载指令后,得知有文件下载任务,开始获取文件数据块,进而根据文件下载指令将获取到的文件数据块下载至指定位置。对该流程进行分析后,确定对于SDK来说,获取下载文件的相关数据(包括文件名、大小、位置、文件上下文环境、文件数据等)对应的各个函数,以及根据下载文件相关数据将文件下载至指定位置对应的各个函数均可被认为是基本函数,对这些基本函数进行抽象和封装,最终生成SDK的下载接口。Analyze the file download process of the cloud storage system, obtain the basic function of completing the file download task from all the file download functions; abstract the basic function into the application callback information class, and according to the basis This function defines the member variables in the application callback information class; uses member variables to pass parameters between the basic functions, and determines the calling order of the basic functions according to the file downloading process; encapsulates the application callback information class and the basic functions that determine the calling order into SDKs. Download interface. For example, when the cloud storage system downloads the file, the client sends a file download instruction, and after receiving the file download instruction, the cloud storage server learns that there is a file download task, starts to acquire the file data block, and then according to the file download instruction. The obtained file data block is downloaded to the specified location. After analyzing the process, it is determined that for the SDK, each function corresponding to the downloaded data (including file name, size, location, file context, file data, etc.) is obtained, and the file is downloaded according to the data related to the downloaded file. Each function corresponding to the specified position can be regarded as a basic function, and these basic functions are abstracted and encapsulated, and finally the download interface of the SDK is generated.
(1)抽象成的统一的应用回调信息类为:(1) The abstracted application callback information class is:
Class com.qihoo.yunpan.sdk.android.task.TransferStatus;其包括的成员变量有:Class com.qihoo.yunpan.sdk.android.task.TransferStatus; its included member variables are:
名称:actionTypeName: actionType
类型:ActionType,描述:当前传送状态Type: ActionType, Description: Current delivery status
名称:localFileNameName: localFileName
类型:String,描述:本地文件名Type: String, Description: Local file name
名称:remoteFileNameName: remoteFileName
类型:String,描述:云存储端文件名Type: String, Description: Cloud storage file name
名称:requestCodeName: requestCode
类型:String,描述:请求code(应用自行控制)Type: String, Description: Request code (application control)
其中,ActionType(消息类型枚举)为com.qihoo.yunpan.sdk.android.task.TransferStatus.ActionType,其值包括:The ActionType (message type enumeration) is com.qihoo.yunpan.sdk.android.task.TransferStatus.ActionType, and its values include:
名称:NULL Name: NULL
描述:无意义Description: meaningless
名称:DOWNLOAD_PROCESSINGName: DOWNLOAD_PROCESSING
描述:下载任务处理中Description: Download task processing
名称:DOWNLOAD_TRANSFER_DATAName: DOWNLOAD_TRANSFER_DATA
描述:下载任务中正在下载数据Description: Downloading data in the download task
名称:DOWNLOAD_COMPLETEName: DOWNLOAD_COMPLETE
描述:下载任务完成Description: Download task completed
(2)构造文件下载函数,实现文件下载任务(2) construct file download function to achieve file download task
如,生成Class com.qihoo.yunpan.sdk.android.task.DownloadTask类For example, generate Class com.qihoo.yunpan.sdk.android.task.DownloadTask class
构造函数:DownloadTask()Constructor: DownloadTask()
参数1:(名称:localFileName,类型:String,描述:本地文件名)Parameter 1: (name: localFileName, type: String, description: local file name)
参数2:(名称:remoteFileName,类型:String,描述:云存储端文件名)Parameter 2: (name: remoteFileName, type: String, description: cloud storage file name)
参数3:(名称:download_handler,类型:Handler,描述:传达消息)Parameter 3: (name: download_handler, type: Handler, description: convey message)
实现上述应用回调信息类和下载函数后,即可封装为下载接口向外提供。After the above application callback information class and download function are implemented, the package interface can be provided as a download interface.
优选地,在下载接口中还可以设置下载进度步长:(默认为5%触发一次,最小1,最大20),可以通过调用setProgressStep()和getProgressStep()方法设置返回数据集的位置。Preferably, the download progress step size can also be set in the download interface: (default is 5% trigger once, minimum 1 and maximum 20), and the position of the returned data set can be set by calling setProgressStep() and getProgressStep().
优选地,在下载接口中还可以设置停止当前任务:(如果重新开始,请将当前任务重新在线程容器中启动),可以通过调用setIsRun(false)停止当前任务。Preferably, the current task can also be set in the download interface: (If restarting, restart the current task in the thread container), the current task can be stopped by calling setIsRun(false).
优选地,在下载接口中还可以设置单任务运行时的线程数:(默认为1,最大5),可以通过调用setDownloadThreadNum(下载任务线程数)设置。通过设置线程数,实现SDK封装的下载任务支持JAVA标准的多线程环境。 Preferably, the number of threads in a single task runtime can also be set in the download interface: (default is 1, maximum 5), which can be set by calling setDownloadThreadNum. By setting the number of threads, the download task of the SDK package supports the JAVA standard multi-threaded environment.
其它主要云盘SDK方法还包括:Other major cloud disk SDK methods also include:
a、用户注册(UserIntfRegister)a, user registration (UserIntfRegister)
生成Class com.qihoo.yunpan.sdk.android.http.action.UserIntfRegister类Generate Class com.qihoo.yunpan.sdk.android.http.action.UserIntfRegister class
构造函数如下:The constructor is as follows:
函数名:doUserIntfRegister()Function name: doUserIntfRegister()
参数1:(名称:userName,类型:String,描述:用户名)Parameter 1: (name: userName, type: String, description: username)
参数2:(名称:passWord,类型:String,描述:密码)Parameter 2: (name: passWord, type: String, description: password)
(如果调用完获取验证码接口后,请将sc参数通过setSc()传入,setCaptcha()方法传入用户输入的验证码)(If you call the get verification code interface, please pass the sc parameter via setSc(), and the setCaptcha() method will pass the verification code entered by the user)
返回类型:UserCenterInfoReturn type: UserCenterInfo
(如果返回值中的errno=5010,需要调用方法获取验证码(UserIntfGetCaptcha)获取)(If the errno=5010 in the return value, you need to call the method to get the verification code (UserIntfGetCaptcha) to get)
b、用户登录(UserIntfLogin)b, user login (UserIntfLogin)
生成Class com.qihoo.yunpan.sdk.android.http.action.UserIntfLogin类Generate Class com.qihoo.yunpan.sdk.android.http.action.UserIntfLogin class
构造函数如下:The constructor is as follows:
函数名:login()Function name: login()
参数1:(名称:username,类型:String,描述:用户名)Parameter 1: (name: username, type: String, description: username)
参数2:(名称:passWord,类型:String,描述:密码)Parameter 2: (name: passWord, type: String, description: password)
参数3:(名称:captcha,类型:String,描述:用户输入的验证码)Parameter 3: (name: captcha, type: String, description: the verification code entered by the user)
参数4:(名称:sc,类型:String,描述:服务器返回的sc参数)Parameter 4: (name: sc, type: String, description: sc parameter returned by the server)
(如果调用完获取验证码接口后,请将captcha和sc参数赋值,没有验证码时给空值)(If you call the get verification code interface, please assign the captcha and sc parameters, and leave a null value when there is no verification code)
返回类型:UserCenterInfoReturn type: UserCenterInfo
(如果返回值中的errno=5010,需要调用方法获取验证码(UserIntfGetCaptcha)获取)(If the errno=5010 in the return value, you need to call the method to get the verification code (UserIntfGetCaptcha) to get)
c、获取云盘列表(FileGetNodeList)c, get the cloud disk list (FileGetNodeList)
生成Class com.qihoo.yunpan.sdk.android.http.action.getNodeList类Generate Class com.qihoo.yunpan.sdk.android.http.action.getNodeList class
构造函数如下: The constructor is as follows:
函数名:getNodeList()Function name: getNodeList()
参数:(名称:path,类型:String,描述:云盘目录,/为根目录)Parameters: (name: path, type: String, description: cloud disk directory, / is the root directory)
返回类型:FileNodeListReturn type: FileNodeList
分页功能:(两项同时设置才生效,默认为从0开始全部)Pagination function: (Two simultaneous settings take effect, the default is all from 0)
包括:通过调用setStart()和getStart()方法设置返回数据集的位置,通过调用setCount()和getCount()方法设置返回数据集的数量;实现排序功能:通过调用setOrderParam()和getOrderParam()方法设置排序字段(默认为按文件名排序),通过调用setIsdesc()和isIsdesc()方法设置正序或倒序(默认为正序);设置内部类This includes setting the position of the returned dataset by calling the setStart() and getStart() methods, and setting the number of returned datasets by calling the setCount() and getCount() methods; implementing the sorting function: by calling the setOrderParam() and getOrderParam() methods Set the sort field (the default is to sort by file name), set the positive or reverse order by calling setIsdesc() and isIsdesc() (the default is positive); set the inner class
enum com.qihoo.yunpan.sdk.android.http.action.getNodeList.OrderTypeEnum com.qihoo.yunpan.sdk.android.http.action.getNodeList.OrderType
该内部类枚举类型的值包括:The values of this inner class enumeration type include:
名称:nameName: name
描述:按文件名Description: by file name
名称:mtimeName: mtime
描述:按修改时间Description: By modification time
名称:fsizeName: fsize
描述:按文件大小Description: by file size
上述其它主要云盘SDK方法中的一种或多种均可以可选方式封装入下载接口中,为用户下载文件提供更好的使用体验。One or more of the other major cloud disk SDK methods may be encapsulated into the download interface in an optional manner to provide a better user experience for downloading files.
步骤二:使用生成的SDK下载接口下载文件。Step 2: Download the file using the generated SDK download interface.
一种使用步骤一中生成的下载接口下载文件的流程如图6所示,该流程包括:A process for downloading a file using the download interface generated in step one is as shown in FIG. 6, and the process includes:
步骤S602:接收文件下载指令,下载任务开始。Step S602: Receive a file download instruction, and the download task starts.
步骤S604:SDK下载接口中的文件下载函数获取下载任务信息。Step S604: The file download function in the SDK download interface acquires the download task information.
其中,获取的下载任务信息包括:待下载文件的信息和待下载文件的统 一上下文环境。The obtained download task information includes: information of the file to be downloaded and a file to be downloaded. A context.
步骤S606:SDK下载接口中的文件下载函数判断待下载的文件数据在客户端本地是否已存在,若否,则执行步骤S608;若是,则执行步骤S612。Step S606: The file download function in the SDK download interface determines whether the file data to be downloaded exists locally in the client. If not, step S608 is performed; if yes, step S612 is performed.
步骤S608:SDK下载接口中的文件下载函数获取待下载的文件的文件块信息。Step S608: The file download function in the SDK download interface acquires file block information of the file to be downloaded.
步骤S610:若本次文件下载完成,则转步骤S612;否则,本次文件下载失败。Step S610: If the download of the file is completed, go to step S612; otherwise, the file download fails.
步骤S612:SDK下载接口中的文件下载函数提示下载完成。Step S612: The file download function in the SDK download interface prompts that the download is completed.
通过本实施例,实现了在android系统的移动终端上,通过SDK实现文件下载的任务,大幅减少了移动终端开发人员的开发难度和提高了移动终端开发效率和开发质量,加快了开发速度,降低了开发成本,有效避免了开发缺陷。Through the embodiment, the task of downloading files through the SDK is realized on the mobile terminal of the android system, the development difficulty of the mobile terminal developer is greatly reduced, the development efficiency and development quality of the mobile terminal are improved, the development speed is accelerated, and the development speed is lowered. The development cost effectively avoids development defects.
实施例七Example 7
参照图7,示出了根据本发明实施例七的一种SDK实现文件上传的装置的结构框图。Referring to FIG. 7, a block diagram of a device for implementing file uploading by an SDK according to Embodiment 7 of the present invention is shown.
本实施例的SDK实现文件上传的装置中的SDK应用于云存储系统,该装置包括:The SDK in the device for uploading a file in the SDK of this embodiment is applied to a cloud storage system, and the device includes:
第一获取模块702,用于接收文件上传指令,获取待上传文件的信息及上传所述待上传文件的统一上下文环境;上传模块704,用于通过上传接口中设定的应用回调信息类中的成员变量,调用上传接口中封装的多个文件上传函数,使多个文件上传函数根据待上传文件的信息,使用统一上下文环境进行待上传的文件的上传。The first obtaining module 702 is configured to receive a file uploading instruction, obtain the information of the file to be uploaded, and upload a unified context of the file to be uploaded; the uploading module 704 is configured to use the application callback information class set in the uploading interface. The member variable invokes multiple file upload functions encapsulated in the upload interface, so that multiple file upload functions use the unified context to upload the file to be uploaded according to the information of the file to be uploaded.
通过本实施例,SDK的上传接口提供了较好的对外合作机制,该上传接口通过对云存储端上传文件的方法进行抽象和封装,生成具有应用回调信息类中的成员变量和多个文件上传函数。在使用该SDK进行文件上传时,一次性获取上传待上传文件的统一上下文环境,在该统一上下文环境下,通过上传接口中的应用回调信息类中的成员变量调用文件上传函数,即可实现文件上传,无需开发人员熟悉上传文件所使用的各个SDK的接口的实现方式 和功能,也无需开发人员熟悉上传文件的各个任务环节和各个任务环节所使用的API接口,从而大幅减少了开发人员的开发难度和提高了开发效率和开发质量,加快了开发速度,降低了开发成本,有效避免了开发缺陷。In this embodiment, the uploading interface of the SDK provides a good external cooperation mechanism. The uploading interface abstracts and encapsulates the method for uploading files on the cloud storage end, and generates member variables and multiple file uploads in the application callback information class. function. When using the SDK for file uploading, the unified context for uploading the file to be uploaded is obtained at one time. In the unified context, the file upload function is called by the member variable in the application callback information class in the upload interface, and the file can be implemented. Upload, no need for developers to be familiar with the implementation of the interface of each SDK used to upload files And functions, without the need for developers to be familiar with the various task links of uploading files and the API interfaces used in each task link, thus greatly reducing the development difficulty of developers and improving development efficiency and development quality, speeding up development and reducing development. Cost, effectively avoiding development defects.
实施例八Example eight
参照图8,示出了根据本发明实施例八的一种SDK实现文件上传的装置的结构框图。Referring to FIG. 8, there is shown a structural block diagram of an apparatus for implementing file uploading by an SDK according to Embodiment 8 of the present invention.
本实施例的SDK实现文件上传的装置中的SDK应用于云存储系统,该装置包括:第一获取模块802,用于接收文件上传指令,获取待上传文件的信息及上传所述待上传文件的统一上下文环境;上传模块804,用于通过上传接口中设定的应用回调信息类中的成员变量,调用上传接口中封装的多个文件上传函数,使多个文件上传函数根据待上传文件的信息,使用统一上下文环境进行待上传的文件的上传。The SDK in the device for uploading the file in the embodiment of the present invention is applied to the cloud storage system, and the device includes: a first obtaining module 802, configured to receive a file uploading instruction, obtain information of the file to be uploaded, and upload the file to be uploaded. The unified context environment; the uploading module 804 is configured to invoke multiple file uploading functions encapsulated in the uploading interface by uploading the member variables in the application callback information class set in the interface, so that multiple file uploading functions are based on the information of the file to be uploaded. , use the unified context to upload files to be uploaded.
优选地,本实施例的SDK实现文件上传的装置还包括:第一封装模块806,用于将多个文件上传函数通过以下方式预先封装在所述上传接口中:对云存储系统的文件上传流程进行分析,从所有文件上传函数中获取完成文件上传任务的基本函数;将基本函数抽象为应用回调信息类,并根据基本函数定义应用回调信息类中的成员变量;使用成员变量在基本函数间传递参数,并按照文件上传流程确定基本函数的调用顺序;将应用回调信息类和确定了调用顺序的基本函数封装成上传接口。Preferably, the device for uploading the file in the SDK of the embodiment further includes: a first encapsulating module 806, configured to pre-package the plurality of file uploading functions in the uploading interface in the following manner: a file uploading process to the cloud storage system Analyze, obtain the basic function of completing the file upload task from all file upload functions; abstract the basic function into the application callback information class, and define the member variables in the application callback information class according to the basic function; use member variables to pass between the basic functions Parameters, and determine the calling order of the basic function according to the file uploading process; package the application callback information class and the basic function that determines the calling sequence into an upload interface.
优选地,上传接口中还封装有上传线程参数;本实施例的SDK实现文件上传的装置还包括:第一线程设置模块808,用于在上传模块804通过上传接口中设定的应用回调信息类中的成员变量,调用上传接口中封装的多个文件上传函数之前,接收上传线程参数设置指令,根据上传线程参数设置指令设置的上传线程参数,启动上传线程参数指示数量的上传线程进行待上传的文件的上传。Preferably, the uploading interface further includes an uploading thread parameter. The device for uploading the file in the SDK of the embodiment further includes: a first thread setting module 808, configured to upload an application callback information class in the uploading module 804 through the uploading interface. In the member variable, before calling the file upload function encapsulated in the upload interface, receiving the upload thread parameter setting instruction, starting the upload thread parameter set by the upload thread parameter setting instruction, starting the upload thread of the upload thread parameter indicating the number to be uploaded. File upload.
优选地,上传模块804在通过上传接口中设定的应用回调信息类中的成员变量,调用上传接口中封装的多个文件上传函数时:由上传接口通过使用设定的应用回调信息类中的成员变量以及句柄参数,调用上传接口中封装的 多个文件上传函数;其中,句柄参数用于在多个文件上传函数之间传达消息。Preferably, the uploading module 804 calls a plurality of file uploading functions encapsulated in the uploading interface by using a member variable in the application callback information class set in the uploading interface: by using the uploading interface by using the set application callback information class Member variables and handle parameters, called in the upload interface encapsulated Multiple file upload functions; where the handle parameters are used to convey messages between multiple file upload functions.
优选地,上传接口中还封装有文件秒传函数;本实施例的SDK实现文件上传的装置还包括:秒传模块810,用于在第一获取模块802接收文件上传指令,获取待上传文件的信息及上传所述待上传文件的统一上下文环境之后,调用文件秒传函数根据待上传文件的信息,判断待上传文件在云存储端是否已存在;若待上传文件在云存储端已存在,则建立用户的用户标识与已存在的文件之间的链接。Preferably, the file uploading function is further encapsulated in the uploading interface. The device for uploading the file in the SDK of the embodiment further includes: a second transmitting module 810, configured to receive the file uploading instruction in the first obtaining module 802, and obtain the file to be uploaded. After the information and the unified context of the file to be uploaded are uploaded, the file second pass function is used to determine whether the file to be uploaded exists on the cloud storage end according to the information of the file to be uploaded; if the file to be uploaded already exists on the cloud storage end, Establish a link between the user's user ID and the existing file.
本实施例的SDK实现文件上传的装置用于实现前述多个方法实施例中相应的SDK实现文件上传的方法,并具有相应的方法实施例的有益效果,在此不再赘述。The device for uploading a file in the SDK of the embodiment is used to implement the method for uploading the corresponding SDK in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, and details are not described herein again.
实施例九Example nine
参照图9,示出了根据本发明实施例九的一种SDK实现文件下载的装置的结构框图。Referring to FIG. 9, a block diagram of a device for implementing file downloading by an SDK according to Embodiment 9 of the present invention is shown.
本实施例的SDK实现文件下载的装置中的SDK应用于云存储系统,该装置包括:The SDK in the device for implementing file downloading in the SDK of this embodiment is applied to a cloud storage system, and the device includes:
接收模块902,用于接收文件下载指令,该文件下载指令中携带有待下载文件的信息;第二获取模块904,用于根据文件下载指令和待下载文件的信息,从云存储端获取待下载文件,并且,获取下载待下载文件的统一上下文环境;下载模块906,用于通过下载接口中设定的应用回调信息类中的成员变量,调用下载接口中封装的多个文件下载函数,使多个文件下载函数使用统一上下文环境进行待下载文件的下载。The receiving module 902 is configured to receive a file downloading instruction, where the file downloading instruction carries the information of the file to be downloaded, and the second obtaining module 904 is configured to obtain the file to be downloaded from the cloud storage end according to the file downloading instruction and the information of the file to be downloaded. And obtaining a unified context environment for downloading the file to be downloaded; the downloading module 906 is configured to invoke multiple file download functions encapsulated in the download interface by using a member variable in the application callback information class set in the download interface, so that multiple The file download function uses a unified context to download the files to be downloaded.
通过本实施例,SDK的下载接口提供了较好的对外合作机制,该下载接口通过对云存储端下载文件的方法进行抽象和封装,生成具有应用回调信息类中的成员变量和多个文件下载函数。在使用该SDK进行文件下载时,一次性获取下载待下载文件的统一上下文环境,在该统一上下文环境下,通过下载接口中的应用回调信息类中的成员变量调用文件下载函数,即可实现文件下载,无需开发人员熟悉下载文件所使用的各个SDK的接口的实现方式和功能,也无需开发人员熟悉下载文件的各个任务环节和各个任务环节所使 用的API接口,从而大幅减少了开发人员的开发难度和提高了开发效率和开发质量,加快了开发速度,降低了开发成本,有效避免了开发缺陷。Through the embodiment, the download interface of the SDK provides a good external cooperation mechanism. The download interface abstracts and encapsulates the method for downloading files on the cloud storage end, and generates member variables and multiple file downloads in the application callback information class. function. When the file is downloaded by using the SDK, the unified context for downloading the file to be downloaded is obtained at one time. In the unified context, the file download function is called by the member variable in the application callback information class in the download interface, and the file can be implemented. Download, no need for developers to be familiar with the implementation and functions of the interfaces of the various SDKs used to download files, nor the need for developers to be familiar with the various task links and task links of downloading files. The API interface is used, which greatly reduces the development difficulty of developers and improves development efficiency and development quality, speeds up development, reduces development costs, and effectively avoids development defects.
实施例十Example ten
参照图10,示出了根据本发明实施例十的一种SDK实现文件下载的装置的结构框图。Referring to FIG. 10, a block diagram showing the structure of an apparatus for implementing file downloading by an SDK according to Embodiment 10 of the present invention is shown.
本实施例的SDK实现文件下载的装置中的SDK应用于云存储系统,该装置包括:接收模块1002,用于接收文件下载指令,该文件下载指令中携带有待下载文件的信息;第二获取模块1004,用于根据文件下载指令和待下载文件的信息,从云存储端获取待下载文件,并且,获取下载待下载文件的统一上下文环境;下载模块1006,用于通过下载接口中设定的应用回调信息类中的成员变量,调用下载接口中封装的多个文件下载函数,使多个文件下载函数使用统一上下文环境进行待下载文件的下载。The SDK in the device for downloading the file in the embodiment of the present invention is applied to the cloud storage system, and the device includes: a receiving module 1002, configured to receive a file downloading instruction, where the file downloading instruction carries information of the file to be downloaded; and the second acquiring module 1004, configured to obtain a file to be downloaded from the cloud storage terminal according to the file downloading instruction and the information to be downloaded, and obtain a unified context for downloading the file to be downloaded; and the downloading module 1006 is configured to download the application set in the interface. The member variable in the callback information class calls multiple file download functions encapsulated in the download interface, so that multiple file download functions use a unified context to download the file to be downloaded.
优选地,本实施例的SDK实现文件下载的装置还包括:第二封装模块1008,用于将多个文件下载函数通过以下方式预先封装在上下载接口中:对云存储系统的文件下载流程进行分析,从所有文件下载函数中获取完成文件下载任务的基本函数;将基本函数抽象为应用回调信息类,并根据基本函数定义应用回调信息类中的成员变量;使用成员变量在基本函数间传递参数,并按照文件下载流程确定基本函数的调用顺序;将应用回调信息类和确定了调用顺序的基本函数封装成下载接口。Preferably, the apparatus for downloading the file of the SDK in this embodiment further includes: a second encapsulating module 1008, configured to pre-package the plurality of file downloading functions in the upper downloading interface by: performing a file downloading process of the cloud storage system Analysis, get the basic function of completing the file download task from all file download functions; abstract the basic function into the application callback information class, and define the member variables in the callback information class according to the basic function; use the member variable to pass the parameters between the basic functions And according to the file download process to determine the calling order of the basic function; the application callback information class and the basic function that determines the calling sequence are packaged into a download interface.
优选地,下载接口中还封装有下载历史记录函数;本实施例的SDK实现文件下载的装置还包括:有效判定模块1010,用于在接收模块1002接收文件下载指令之后,使用下载接口中的应用回调信息类中的成员变量,调用下载接口中封装的下载历史记录函数,通过下载历史记录函数判断发送文件下载指令的客户端是否已下载过待下载文件;若已下载过,则判断客户端中已下载的待下载文件是否有效;若有效,则结束待下载文件的下载;若无效或者若未下载过待下载文件,则进入第二获取模块1004。Preferably, the download interface further includes a download history function; the device for downloading the file in the SDK of the embodiment further includes: an effective determining module 1010, configured to use the application in the download interface after the receiving module 1002 receives the file download command Calling the member variable in the information class, calling the download history function encapsulated in the download interface, and determining whether the client that sent the file download instruction has downloaded the file to be downloaded by downloading the history function; if it has been downloaded, determining the client Whether the downloaded file to be downloaded is valid; if it is valid, the download of the file to be downloaded is ended; if it is invalid or if the file to be downloaded has not been downloaded, the second obtaining module 1004 is entered.
优选地,下载接口中还封装有下载线程参数;;本实施例的SDK实现文件下载的装置还包括:第二线程设置模块1012,用于在第二获取模块1004 根据文件下载指令和待下载文件的信息,从云存储端获取待下载文件,并且,获取下载待下载文件的统一上下文环境之前,接收下载线程参数设置指令,根据下载线程参数设置指令设置的下载线程参数,启动下载线程参数指示数量的下载线程进行待下载文件的下载。Preferably, the downloading interface further includes a downloading thread parameter; the device for downloading the file in the SDK of the embodiment further includes: a second thread setting module 1012, configured to be in the second obtaining module 1004 Obtaining a file to be downloaded from the cloud storage terminal according to the file downloading instruction and the information of the file to be downloaded, and obtaining a downloading thread parameter setting instruction according to the downloading thread parameter setting instruction before obtaining the unified context environment for downloading the file to be downloaded The parameter starts the download thread parameter indicating the number of download threads to download the file to be downloaded.
优选地,下载模块1006在通过下载接口中设定的应用回调信息类中的成员变量,调用下载接口中封装的多个文件下载函数时:由下载接口通过使用设定的应用回调信息类中的成员变量以及句柄参数,调用下载接口中封装的多个文件下载函数;其中,句柄参数用于在多个文件下载函数之间传达消息。Preferably, the downloading module 1006 invokes a plurality of file download functions encapsulated in the download interface by using a member variable in the application callback information class set in the download interface: by using the downloaded interface in the set application callback information class The member variable and the handle parameter call multiple file download functions encapsulated in the download interface; wherein the handle parameter is used to convey a message between multiple file download functions.
本实施例的SDK实现文件下载的装置用于实现前述多个方法实施例中相应的SDK实现文件下载的方法,并具有相应的方法实施例的有益效果,在此不再赘述。The apparatus for downloading the file in the SDK of the embodiment is used to implement the method for downloading the corresponding SDK in the foregoing multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, and details are not described herein again.
在此提供的SDK实现文件上传和/或下载的方案不与任何特定计算机、虚拟系统或者其它设备固有相关。各种通用系统也可以与基于在此的示教一起使用。根据上面的描述,构造具有本发明方案的系统所要求的结构是显而易见的。此外,本发明也不针对任何特定编程语言。应当明白,可以利用各种编程语言实现在此描述的本发明的内容,并且上面对特定语言所做的描述是为了披露本发明的最佳实施方式。The SDK implementation file uploading and/or downloading scheme provided herein is not inherently related to any particular computer, virtual system, or other device. Various general purpose systems can also be used with the teaching based on the teachings herein. According to the above description, it is obvious that the structure required to construct the system having the solution of the present invention is obvious. Moreover, the invention is not directed to any particular programming language. It is to be understood that the invention may be embodied in a variety of programming language, and the description of the specific language has been described above in order to disclose the preferred embodiments of the invention.
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。In the description provided herein, numerous specific details are set forth. However, it is understood that the embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques are not shown in detail so as not to obscure the understanding of the description.
类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身 都作为本发明的单独实施例。Similarly, the various features of the invention are sometimes grouped together into a single embodiment, in the above description of the exemplary embodiments of the invention, Figure, or a description of it. However, the method disclosed is not to be interpreted as reflecting the intention that the claimed invention requires more features than those recited in the claims. Rather, as the following claims reflect, inventive aspects lie in less than all features of the single embodiments disclosed herein. Therefore, the claims following the specific embodiments are hereby explicitly incorporated into the specific embodiments, wherein each claim itself Both are separate embodiments of the invention.
本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。Those skilled in the art will appreciate that the modules in the devices of the embodiments can be adaptively changed and placed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components. In addition to such features and/or at least some of the processes or units being mutually exclusive, any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed, or All processes or units of the device are combined. Each feature disclosed in this specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose.
此外,本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。In addition, those skilled in the art will appreciate that, although some embodiments described herein include certain features that are included in other embodiments and not in other features, combinations of features of different embodiments are intended to be within the scope of the present invention. Different embodiments are formed and formed. For example, in the claims, any one of the claimed embodiments can be used in any combination.
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的SDK实现文件上传的方案中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。The various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or digital signal processor (DSP) may be used in practice to implement some or all of the functionality of some or all of the components of the SDK implementation file uploading in accordance with embodiments of the present invention. The invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein. Such a program implementing the invention may be stored on a computer readable medium or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
例如,图11示出了可以实现根据本发明的SDK实现文件上传和/或下载的计算设备,例如应用服务器。该服务器传统上包括处理器1110和以存储器1120形式的计算机程序产品或者计算机可读介质。存储器1120可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。存储器1120具有用于执行上述方法中的任何方法步骤的程序代码1131的存储空间1130。例如,用于程序代码的存储空间1130 可以包括分别用于实现上面的方法中的各种步骤的各个程序代码1131。这些程序代码可以从一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程序产品中。这些计算机程序产品包括诸如硬盘,紧致盘(CD)、存储卡或者软盘之类的程序代码载体。这样的计算机程序产品通常为如参考图12所述的便携式或者固定存储单元。该存储单元可以具有与图11的服务器中的存储器1120类似布置的存储段、存储空间等。程序代码可以例如以适当形式进行压缩。通常,存储单元包括计算机可读代码1131’,即可以由例如诸如1110之类的处理器读取的代码,这些代码当由服务器运行时,导致该服务器执行上面所描述的方法中的各个步骤。For example, Figure 11 illustrates a computing device, such as an application server, that can implement file upload and/or download in accordance with the SDK of the present invention. The server conventionally includes a processor 1110 and a computer program product or computer readable medium in the form of a memory 1120. The memory 1120 may be an electronic memory such as a flash memory, an EEPROM (Electrically Erasable Programmable Read Only Memory), an EPROM, a hard disk, or a ROM. Memory 1120 has a memory space 1130 for program code 1131 for performing any of the method steps described above. For example, storage space 1130 for program code Each program code 1131 for implementing various steps in the above method may be included. The program code can be read from or written to one or more computer program products. These computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks. Such a computer program product is typically a portable or fixed storage unit as described with reference to FIG. The storage unit may have a storage section, a storage space, and the like arranged similarly to the storage 1120 in the server of FIG. The program code can be compressed, for example, in an appropriate form. Typically, the storage unit includes computer readable code 1131', i.e., code that can be read by, for example, a processor such as 1110, which when executed by a server causes the server to perform various steps in the methods described above.
本文中所称的“一个实施例”、“实施例”或者“一个或者多个实施例”意味着,结合实施例描述的特定特征、结构或者特性包括在本发明的至少一个实施例中。此外,请注意,这里“在一个实施例中”的词语例子不一定全指同一个实施例。&quot;an embodiment,&quot; or &quot;an embodiment,&quot; or &quot;an embodiment,&quot; In addition, it is noted that the phrase "in one embodiment" is not necessarily referring to the same embodiment.
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下被实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。In the description provided herein, numerous specific details are set forth. However, it is understood that the embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques are not shown in detail so as not to obscure the understanding of the description.
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包括”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。It is to be noted that the above-described embodiments are illustrative of the invention and are not intended to be limiting, and that the invention may be devised without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as a limitation. The word 'comprising' does not exclude the presence of the elements or steps that are not recited in the claims. The word "a" or "an" The invention can be implemented by means of hardware comprising several distinct elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means can be embodied by the same hardware item. The use of the words first, second, and third does not indicate any order. These words can be interpreted as names.
此外,还应当注意,本说明书中使用的语言主要是为了可读性和教导的目的而选择的,而不是为了解释或者限定本发明的主题而选择的。因此,在不偏离所附权利要求书的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。对于本发明的范围,对本发明所 做的公开是说明性的,而非限制性的,本发明的范围由所附权利要求书限定。 In addition, it should be noted that the language used in the specification has been selected for the purpose of readability and teaching, and is not intended to be construed or limited. Therefore, many modifications and changes will be apparent to those skilled in the art without departing from the scope of the invention. For the scope of the present invention, the present invention The disclosure is intended to be illustrative, and not restrictive, and the scope of the invention is defined by the appended claims.

Claims (24)

  1. 一种软件开发工具包实现文件上传的方法,所述软件开发工具包应用于云存储系统,所述方法包括:A software development kit for implementing file uploading, the software development kit being applied to a cloud storage system, the method comprising:
    接收文件上传指令,获取待上传文件的信息及上传所述待上传文件的统一上下文环境;以及Receiving a file uploading instruction, obtaining information of the file to be uploaded, and uploading a unified context of the file to be uploaded;
    通过上传接口中设定的应用回调信息类中的成员变量,调用所述上传接口中封装的多个文件上传函数,使所述多个文件上传函数根据所述待上传文件的信息,使用所述统一上下文环境进行所述待上传的文件的上传。And calling, by the member variable in the application callback information class set in the uploading interface, a plurality of file uploading functions encapsulated in the uploading interface, so that the multiple file uploading functions use the information according to the information of the file to be uploaded. The unified context is used to upload the file to be uploaded.
  2. 根据权利要求1所述的方法,其中,所述多个文件上传函数通过以下方式预先封装在所述上传接口中:The method of claim 1, wherein the plurality of file upload functions are pre-packaged in the upload interface by:
    对所述云存储系统的文件上传流程进行分析,从所有文件上传函数中获取完成文件上传任务的基本函数;Performing an analysis on the file uploading process of the cloud storage system, and obtaining a basic function of completing the file uploading task from all file uploading functions;
    将所述基本函数抽象为所述应用回调信息类,并根据所述基本函数定义所述应用回调信息类中的成员变量;Extracting the basic function into the application callback information class, and defining a member variable in the application callback information class according to the basic function;
    使用所述成员变量在所述基本函数间传递参数,并按照所述文件上传流程确定所述基本函数的调用顺序;以及Passing parameters between the basic functions using the member variables, and determining a calling order of the basic functions according to the file uploading process;
    将所述应用回调信息类和确定了调用顺序的所述基本函数封装成所述上传接口。The application callback information class and the basic function that determines the calling sequence are encapsulated into the upload interface.
  3. 根据权利要求2所述的方法,其中,所述上传接口中还封装有上传线程参数;The method of claim 2, wherein the uploading interface further encapsulates an upload thread parameter;
    在所述通过上传接口中设定的应用回调信息类中的成员变量,调用所述上传接口中封装的多个文件上传函数的步骤之前,还包括:Before the step of calling the multiple file uploading functions encapsulated in the uploading interface by using the member variable in the application callback information class set in the uploading interface, the method further includes:
    接收上传线程参数设置指令,根据所述上传线程参数设置指令设置的上传线程参数,启动所述上传线程参数指示数量的上传线程进行所述待上传的文件的上传。The uploading thread parameter setting instruction is received, and the uploading thread of the uploading thread parameter indicating quantity is started to upload the file to be uploaded according to the uploading thread parameter set by the uploading thread parameter setting instruction.
  4. 根据权利要求1所述的方法,其中,所述通过上传接口中设定的应用回调信息类中的成员变量,调用所述上传接口中封装的多个文件上传函数的步骤包括:The method according to claim 1, wherein the step of calling a plurality of file upload functions encapsulated in the upload interface by using a member variable in an application callback information class set in an upload interface comprises:
    所述上传接口通过使用设定的应用回调信息类中的成员变量以及句柄 参数,调用所述上传接口中封装的多个文件上传函数;The upload interface uses a member variable and a handle in the set of application callback information classes a parameter, calling a plurality of file upload functions encapsulated in the upload interface;
    其中,所述句柄参数用于在所述多个文件上传函数之间传达消息。Wherein the handle parameter is used to convey a message between the plurality of file upload functions.
  5. 根据权利要求1所述的方法,其中,所述上传接口中还封装有文件秒传函数;The method according to claim 1, wherein the upload interface is further encapsulated with a file second transfer function;
    在所述接收文件上传指令,获取待上传文件的信息及上传所述待上传文件的统一上下文环境的步骤之后,还包括:After the step of receiving the file uploading instruction, obtaining the information of the file to be uploaded, and uploading the unified context of the file to be uploaded, the method further includes:
    调用所述文件秒传函数根据所述待上传文件的信息,判断所述待上传文件在云存储端是否已存在;以及Calling the file second pass function to determine whether the file to be uploaded exists on the cloud storage end according to the information of the file to be uploaded;
    若所述待上传文件在云存储端已存在,则建立所述用户的用户标识与已存在的文件之间的链接。If the file to be uploaded already exists on the cloud storage end, a link between the user identifier of the user and the existing file is established.
  6. 一种软件开发工具包实现文件上传的装置,所述软件开发工具包应用于云存储系统,所述装置包括:A device for implementing file uploading by a software development kit, the software development kit being applied to a cloud storage system, the device comprising:
    第一获取模块,用于接收文件上传指令,获取待上传文件的信息及上传所述待上传文件的统一上下文环境;以及a first acquiring module, configured to receive a file uploading instruction, obtain information about the file to be uploaded, and upload a unified context of the file to be uploaded;
    上传模块,用于通过上传接口中设定的应用回调信息类中的成员变量,调用所述上传接口中封装的多个文件上传函数,使所述多个文件上传函数根据所述待上传文件的信息,使用所述统一上下文环境进行所述待上传的文件的上传。The uploading module is configured to invoke a plurality of file uploading functions encapsulated in the uploading interface by using a member variable in the application callback information class set in the uploading interface, so that the multiple file uploading functions are based on the file to be uploaded. The information is used to upload the file to be uploaded using the unified context.
  7. 根据权利要求6所述的装置,其中,所述装置还包括:The apparatus of claim 6 wherein said apparatus further comprises:
    第一封装模块,用于将所述多个文件上传函数通过以下方式预先封装在所述上传接口中:a first encapsulating module, configured to pre-package the plurality of file uploading functions in the uploading interface by:
    对所述云存储系统的文件上传流程进行分析,从所有文件上传函数中获取完成文件上传任务的基本函数;Performing an analysis on the file uploading process of the cloud storage system, and obtaining a basic function of completing the file uploading task from all file uploading functions;
    将所述基本函数抽象为所述应用回调信息类,并根据所述基本函数定义所述应用回调信息类中的成员变量;Extracting the basic function into the application callback information class, and defining a member variable in the application callback information class according to the basic function;
    使用所述成员变量在所述基本函数间传递参数,并按照所述文件上传流程确定所述基本函数的调用顺序;以及Passing parameters between the basic functions using the member variables, and determining a calling order of the basic functions according to the file uploading process;
    将所述应用回调信息类和确定了调用顺序的所述基本函数封装成所述 上传接口。Encapsulating the application callback information class and the basic function determining the calling sequence into the Upload interface.
  8. 根据权利要求7所述的装置,其中,所述上传接口中还封装有上传线程参数;The device according to claim 7, wherein the uploading interface further encapsulates an upload thread parameter;
    所述装置还包括:The device also includes:
    第一线程设置模块,用于在所述上传模块通过上传接口中设定的应用回调信息类中的成员变量,调用所述上传接口中封装的多个文件上传函数之前,接收上传线程参数设置指令,根据所述上传线程参数设置指令设置的上传线程参数,启动所述上传线程参数指示数量的上传线程进行所述待上传的文件的上传。a first thread setting module, configured to receive an upload thread parameter setting instruction before the uploading module calls a plurality of file uploading functions encapsulated in the uploading interface by using a member variable in an application callback information class set in the uploading interface And uploading, according to the uploading thread parameter set by the uploading thread parameter setting instruction, the uploading thread of the uploading thread parameter indicating the uploading of the file to be uploaded.
  9. 根据权利要求6所述的装置,其中,所述上传模块在通过上传接口中设定的应用回调信息类中的成员变量,调用所述上传接口中封装的多个文件上传函数时:The apparatus according to claim 6, wherein the uploading module invokes a plurality of file uploading functions encapsulated in the uploading interface when a member variable in the application callback information class set in the uploading interface is called:
    由所述上传接口通过使用设定的应用回调信息类中的成员变量以及句柄参数,调用所述上传接口中封装的多个文件上传函数;Calling, by the uploading interface, a plurality of file uploading functions encapsulated in the uploading interface by using a member variable and a handle parameter in the set application callback information class;
    其中,所述句柄参数用于在所述多个文件上传函数之间传达消息。Wherein the handle parameter is used to convey a message between the plurality of file upload functions.
  10. 根据权利要求6所述的装置,其中,所述上传接口中还封装有文件秒传函数;The device according to claim 6, wherein the upload interface is further encapsulated with a file second transfer function;
    所述装置还包括:The device also includes:
    秒传模块,用于在所述第一获取模块接收文件上传指令,获取待上传文件的信息及上传所述待上传文件的统一上下文环境之后,调用所述文件秒传函数根据所述待上传文件的信息,判断所述待上传文件在云存储端是否已存在;若所述待上传文件在云存储端已存在,则建立所述用户的用户标识与已存在的文件之间的链接。a second transmission module, configured to: after receiving the file uploading instruction by the first acquiring module, obtaining the information of the file to be uploaded, and uploading the unified context of the file to be uploaded, calling the file second sending function according to the file to be uploaded If the file to be uploaded exists on the cloud storage end, the link between the user identifier of the user and the existing file is established.
  11. 一种软件开发工具包实现文件下载的方法,所述软件开发工具包应用于云存储系统,所述方法包括:A software development kit implements a method for downloading a file, the software development kit being applied to a cloud storage system, the method comprising:
    接收文件下载指令,所述文件下载指令中携带有待下载文件的信息;Receiving a file download instruction, where the file download instruction carries information of the file to be downloaded;
    根据所述文件下载指令和所述待下载文件的信息,从云存储端获取所述 待下载文件,并且,获取下载所述待下载文件的统一上下文环境;以及Obtaining the information from the cloud storage end according to the file download instruction and the information of the file to be downloaded Waiting for the file to be downloaded, and obtaining a unified context for downloading the file to be downloaded;
    通过下载接口中设定的应用回调信息类中的成员变量,调用所述下载接口中封装的多个文件下载函数,使所述多个文件下载函数使用所述统一上下文环境进行所述待下载文件的下载。Calling, by the member variable in the application callback information class set in the interface, a plurality of file download functions encapsulated in the download interface, so that the plurality of file download functions use the unified context to perform the file to be downloaded Download.
  12. 根据权利要求11所述的方法,其中,所述多个文件下载函数通过以下方式预先封装在所述下载接口中:The method of claim 11 wherein said plurality of file download functions are pre-packaged in said download interface in the following manner:
    对所述云存储系统的文件下载流程进行分析,从所有文件下载函数中获取完成文件下载任务的基本函数;Performing an analysis on the file downloading process of the cloud storage system, and obtaining a basic function of completing the file downloading task from all file downloading functions;
    将所述基本函数抽象为所述应用回调信息类,并根据所述基本函数定义所述应用回调信息类中的成员变量;Extracting the basic function into the application callback information class, and defining a member variable in the application callback information class according to the basic function;
    使用所述成员变量在所述基本函数间传递参数,并按照所述文件下载流程确定所述基本函数的调用顺序;以及Passing parameters between the basic functions using the member variables, and determining a calling order of the basic functions according to the file downloading process;
    将所述应用回调信息类和确定了调用顺序的所述基本函数封装成所述下载接口。The application callback information class and the basic function that determines the calling order are encapsulated into the download interface.
  13. 根据权利要求12所述的方法,其中,所述下载接口中还封装有下载历史记录函数;The method of claim 12, wherein the download interface is further encapsulated with a download history function;
    在所述接收文件下载指令的步骤之后,还包括:After the step of receiving the file download instruction, the method further includes:
    使用所述下载接口中的所述应用回调信息类中的成员变量,调用所述下载接口中封装的所述下载历史记录函数,通过所述下载历史记录函数判断发送所述文件下载指令的客户端是否已下载过所述待下载文件;Using the member variable in the application callback information class in the download interface, calling the download history record function encapsulated in the download interface, and determining, by using the download history record function, a client that sends the file download instruction Whether the file to be downloaded has been downloaded;
    若已下载过,则判断所述客户端中已下载的所述待下载文件是否有效;If it has been downloaded, determining whether the file to be downloaded that has been downloaded in the client is valid;
    若有效,则结束所述待下载文件的下载;If valid, the download of the file to be downloaded is ended;
    若无效或者若未下载过所述待下载文件,则执行所述根据所述文件下载指令和所述待下载文件的信息,从云存储端获取所述待下载文件,并且,获取下载所述待下载文件的统一上下文环境的步骤。If the file to be downloaded is not valid, or if the file to be downloaded is not downloaded, the file to be downloaded is obtained from the cloud storage terminal, and the downloaded file is obtained. The steps to download a unified context for a file.
  14. 根据权利要求12所述的方法,其中,所述下载接口中还封装有下载线程参数;The method of claim 12, wherein the download interface further encapsulates a download thread parameter;
    在所述根据所述文件下载指令和所述待下载文件的信息,从云存储端获 取所述待下载文件,并且,获取下载所述待下载文件的统一上下文环境的步骤之前,还包括:Obtaining information from the cloud storage terminal according to the file download instruction and the information of the file to be downloaded Before the step of downloading the file to be downloaded and obtaining the unified context of the file to be downloaded, the method further includes:
    接收下载线程参数设置指令,根据所述下载线程参数设置指令设置的下载线程参数,启动所述下载线程参数指示数量的下载线程进行所述待下载文件的下载。Receiving a download thread parameter setting instruction, and starting a download thread of the download thread parameter indicating quantity to download the file to be downloaded according to the download thread parameter set by the download thread parameter setting instruction.
  15. 根据权利要求12所述的方法,其中,所述通过下载接口中设定的应用回调信息类中的成员变量,调用所述下载接口中封装的多个文件下载函数的步骤包括:The method according to claim 12, wherein the step of calling the plurality of file download functions encapsulated in the download interface by using a member variable in the application callback information class set in the download interface comprises:
    所述下载接口通过使用设定的应用回调信息类中的成员变量以及句柄参数,调用所述下载接口中封装的多个文件下载函数;The download interface invokes a plurality of file download functions encapsulated in the download interface by using a member variable and a handle parameter in the set application callback information class;
    其中,所述句柄参数用于在所述多个文件下载函数之间传达消息。Wherein the handle parameter is used to convey a message between the plurality of file download functions.
  16. 一种软件开发工具包实现文件下载的装置,所述软件开发工具包应用于云存储系统,所述装置包括:A software development kit for implementing file downloading, the software development kit being applied to a cloud storage system, the device comprising:
    接收模块,用于接收文件下载指令,所述文件下载指令中携带有待下载文件的信息;a receiving module, configured to receive a file downloading instruction, where the file downloading instruction carries information about the file to be downloaded;
    第二获取模块,用于根据所述文件下载指令和所述待下载文件的信息,从云存储端获取所述待下载文件,并且,获取下载所述待下载文件的统一上下文环境;以及a second obtaining module, configured to acquire the file to be downloaded from the cloud storage end according to the file downloading instruction and the information of the file to be downloaded, and obtain a unified context environment for downloading the file to be downloaded;
    下载模块,用于通过下载接口中设定的应用回调信息类中的成员变量,调用所述下载接口中封装的多个文件下载函数,使所述多个文件下载函数使用所述统一上下文环境进行所述待下载文件的下载。a downloading module, configured to invoke a plurality of file downloading functions encapsulated in the download interface by using a member variable in an application callback information class set in the download interface, so that the multiple file download functions are performed by using the unified context environment Downloading of the file to be downloaded.
  17. 根据权利要求16所述的装置,其中,所述装置还包括:The apparatus of claim 16 wherein said apparatus further comprises:
    第二封装模块,用于将所述多个文件下载函数通过以下方式预先封装在所述上下载接口中:a second encapsulating module, configured to pre-package the plurality of file download functions in the upper download interface by:
    对所述云存储系统的文件下载流程进行分析,从所有文件下载函数中获取完成文件下载任务的基本函数;Performing an analysis on the file downloading process of the cloud storage system, and obtaining a basic function of completing the file downloading task from all file downloading functions;
    将所述基本函数抽象为所述应用回调信息类,并根据所述基本函数定义 所述应用回调信息类中的成员变量;Abstracting the basic function into the application callback information class and defining according to the basic function The application calls back a member variable in the information class;
    使用所述成员变量在所述基本函数间传递参数,并按照所述文件下载流程确定所述基本函数的调用顺序;以及Passing parameters between the basic functions using the member variables, and determining a calling order of the basic functions according to the file downloading process;
    将所述应用回调信息类和确定了调用顺序的所述基本函数封装成所述下载接口。The application callback information class and the basic function that determines the calling order are encapsulated into the download interface.
  18. 根据权利要求17所述的装置,其中,所述下载接口中还封装有下载历史记录函数;The device according to claim 17, wherein the download interface is further encapsulated with a download history function;
    所述装置还包括:The device also includes:
    有效判定模块,用于在所述接收模块接收文件下载指令之后,使用所述下载接口中的所述应用回调信息类中的成员变量,调用所述下载接口中封装的所述下载历史记录函数,通过所述下载历史记录函数判断发送所述文件下载指令的客户端是否已下载过所述待下载文件;An effective determining module, configured to: after the receiving module receives the file downloading instruction, use the member variable in the application callback information class in the download interface to invoke the download history record function encapsulated in the download interface, Determining, by the download history function, whether the client that sends the file download instruction has downloaded the file to be downloaded;
    若已下载过,则判断所述客户端中已下载的所述待下载文件是否有效;If it has been downloaded, determining whether the file to be downloaded that has been downloaded in the client is valid;
    若有效,则结束所述待下载文件的下载;If valid, the download of the file to be downloaded is ended;
    若无效或者若未下载过所述待下载文件,则进入所述第二获取模块。If it is invalid or if the file to be downloaded has not been downloaded, the second acquiring module is entered.
  19. 根据权利要求17所述的装置,其中,所述下载接口中还封装有下载线程参数;The device of claim 17, wherein the download interface further encapsulates a download thread parameter;
    所述装置还包括:The device also includes:
    第二线程设置模块,用于在所述第二获取模块根据所述文件下载指令和所述待下载文件的信息,从云存储端获取所述待下载文件,并且,获取下载所述待下载文件的统一上下文环境之前,接收下载线程参数设置指令,根据所述下载线程参数设置指令设置的下载线程参数,启动所述下载线程参数指示数量的下载线程进行所述待下载文件的下载。a second thread setting module, configured to acquire the file to be downloaded from the cloud storage end according to the file downloading instruction and the information of the file to be downloaded, and obtain the downloaded file to be downloaded Before receiving the unified context, the downloading thread parameter setting instruction is received, and the downloading thread of the number of the downloading thread parameter is started to download the file to be downloaded according to the downloading thread parameter set by the downloading thread parameter setting instruction.
  20. 根据权利要求17所述的装置,所述下载模块在通过下载接口中设定的应用回调信息类中的成员变量,调用所述下载接口中封装的多个文件下载函数时:The apparatus according to claim 17, wherein the downloading module invokes a plurality of file download functions encapsulated in the download interface by a member variable in an application callback information class set in a download interface:
    由所述下载接口通过使用设定的应用回调信息类中的成员变量以及句柄参数,调用所述下载接口中封装的多个文件下载函数; Calling, by the download interface, a plurality of file download functions encapsulated in the download interface by using a member variable and a handle parameter in the set application callback information class;
    其中,所述句柄参数用于在所述多个文件下载函数之间传达消息。Wherein the handle parameter is used to convey a message between the plurality of file download functions.
  21. 一种计算机程序,包括计算机可读代码,当所述计算机可读代码在计算设备上运行时,导致所述计算设备执行根据权利要求1-5中的任一个所述的软件开发工具包实现文件上传的方法。A computer program comprising computer readable code, when said computer readable code is run on a computing device, causing said computing device to execute a software development kit implementation file according to any of claims 1-5 Upload method.
  22. 一种计算机可读介质,其中存储了如权利要求21所述的计算机程序。A computer readable medium storing the computer program of claim 21.
  23. 一种计算机程序,包括计算机可读代码,当所述计算机可读代码在计算设备上运行时,导致所述计算设备执行根据权利要求11-15中的任一个所述的软件开发工具包实现文件下载的方法。A computer program comprising computer readable code, when said computer readable code is run on a computing device, causing said computing device to execute a software development kit implementation file according to any of claims 11-15 The method of downloading.
  24. 一种计算机可读介质,其中存储了如权利要求23所述的计算机程序。 A computer readable medium storing the computer program of claim 23.
PCT/CN2014/089765 2013-10-29 2014-10-29 Method and device for sdk uploading and downloading of a file WO2015062494A1 (en)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN201310522737.5 2013-10-29
CN201310522159.5 2013-10-29
CN201310522159.5A CN103595769B (en) 2013-10-29 2013-10-29 Method and device for achieving file uploading through SDK
CN201310522737.5A CN103595770B (en) 2013-10-29 2013-10-29 Method and device for achieving file downloading through SDK

Publications (1)

Publication Number Publication Date
WO2015062494A1 true WO2015062494A1 (en) 2015-05-07

Family

ID=53003357

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/089765 WO2015062494A1 (en) 2013-10-29 2014-10-29 Method and device for sdk uploading and downloading of a file

Country Status (1)

Country Link
WO (1) WO2015062494A1 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109117647A (en) * 2018-07-17 2019-01-01 众安信息技术服务有限公司 A kind of the permission control management method and management system of mobile application SDK
CN112631690A (en) * 2021-01-06 2021-04-09 中煤航测遥感集团有限公司 File in applet and data processing method and device
CN115225686A (en) * 2022-07-13 2022-10-21 全通金信控股(广东)有限公司 Agent client system based on cloud storage
CN117459525A (en) * 2023-12-20 2024-01-26 宁德时代新能源科技股份有限公司 File uploading method, device, equipment and medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102999400A (en) * 2012-11-22 2013-03-27 中国电信股份有限公司云计算分公司 Data backup method and device of cloud storage system
CN103002048A (en) * 2012-12-20 2013-03-27 北京奇虎科技有限公司 System and method for achieving file synchronous storage
CN103269396A (en) * 2013-05-02 2013-08-28 百度在线网络技术(北京)有限公司 Method and system capable of conducting management on mobile terminal
CN103353844A (en) * 2013-06-25 2013-10-16 亿赞普(北京)科技有限公司 Upgrading method and system of SDK (software development kit)
CN103595769A (en) * 2013-10-29 2014-02-19 北京奇虎科技有限公司 Method and device for achieving file uploading through SDK
CN103595770A (en) * 2013-10-29 2014-02-19 北京奇虎科技有限公司 Method and device for achieving file downloading through SDK

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102999400A (en) * 2012-11-22 2013-03-27 中国电信股份有限公司云计算分公司 Data backup method and device of cloud storage system
CN103002048A (en) * 2012-12-20 2013-03-27 北京奇虎科技有限公司 System and method for achieving file synchronous storage
CN103269396A (en) * 2013-05-02 2013-08-28 百度在线网络技术(北京)有限公司 Method and system capable of conducting management on mobile terminal
CN103353844A (en) * 2013-06-25 2013-10-16 亿赞普(北京)科技有限公司 Upgrading method and system of SDK (software development kit)
CN103595769A (en) * 2013-10-29 2014-02-19 北京奇虎科技有限公司 Method and device for achieving file uploading through SDK
CN103595770A (en) * 2013-10-29 2014-02-19 北京奇虎科技有限公司 Method and device for achieving file downloading through SDK

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109117647A (en) * 2018-07-17 2019-01-01 众安信息技术服务有限公司 A kind of the permission control management method and management system of mobile application SDK
CN112631690A (en) * 2021-01-06 2021-04-09 中煤航测遥感集团有限公司 File in applet and data processing method and device
CN115225686A (en) * 2022-07-13 2022-10-21 全通金信控股(广东)有限公司 Agent client system based on cloud storage
CN117459525A (en) * 2023-12-20 2024-01-26 宁德时代新能源科技股份有限公司 File uploading method, device, equipment and medium
CN117459525B (en) * 2023-12-20 2024-04-12 宁德时代新能源科技股份有限公司 File uploading method, device, equipment and medium

Similar Documents

Publication Publication Date Title
US10503493B2 (en) Distributed versioning of applications using cloud-based systems
US10306023B2 (en) Pre-formed instructions for a mobile cloud service
CN103595770B (en) Method and device for achieving file downloading through SDK
CN105357204B (en) Method and device for generating terminal identification information
WO2015062494A1 (en) Method and device for sdk uploading and downloading of a file
US20210191759A1 (en) Elastic Execution of Machine Learning Workloads Using Application Based Profiling
CN110765288B (en) Image information synchronization method, device and system and storage medium
US11216482B2 (en) Systems and methods for access to multi-tenant heterogeneous databases
US11016769B1 (en) Method and apparatus for processing information
US11406901B2 (en) Addressable assets in software development
CN107273226B (en) Method and device for integrating components in android system and calling integrated components
CN103595769B (en) Method and device for achieving file uploading through SDK
Chang et al. Rapid Access Control on Ubuntu Cloud Computing with Facial Recognition and Fingerprint Identification.
CN111580883B (en) Application program starting method, device, computer system and medium
US20230153147A1 (en) Ad-hoc proxy for batch processing task
CN113132400B (en) Business processing method, device, computer system and storage medium
CN112988604B (en) Object testing method, testing system, electronic device and readable storage medium
CN111400281B (en) GIS data quality inspection and storage method for OSS object storage
WO2020064000A1 (en) Method and apparatus for displaying message box, terminal and storage medium
CN106951288A (en) A kind of exploitation, application process and the device of heat more resource
US11843523B1 (en) Microservices anti-pattern discovery
KR102443301B1 (en) Adaptive data processing system for processing various data and method thereof
US20230251844A1 (en) Sparse programming image validation
US20210342308A1 (en) System and method for performing context aware operating file system virtualization
CN110520842B (en) Address space splitting system and method for traditional application compatibility

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14858798

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14858798

Country of ref document: EP

Kind code of ref document: A1