CN107395719A - The determination methods that a kind of FTP multistage directory paths based on iOS whether there is - Google Patents
The determination methods that a kind of FTP multistage directory paths based on iOS whether there is Download PDFInfo
- Publication number
- CN107395719A CN107395719A CN201710595277.7A CN201710595277A CN107395719A CN 107395719 A CN107395719 A CN 107395719A CN 201710595277 A CN201710595277 A CN 201710595277A CN 107395719 A CN107395719 A CN 107395719A
- Authority
- CN
- China
- Prior art keywords
- ftp
- directory
- judged
- multistage
- determination methods
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/06—Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/60—Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
Abstract
The present invention disclose the determination methods that a kind of FTP multistage directory paths based on iOS whether there is, if the series of judged current directory is recorded with static integer variable number, and initialization value is the series 1 for the multistage catalogue to be judged;The determination methods comprise the following steps:Step 1, multistage catalogue to be judged is spliced into the url for meeting FTP, is created by CFReadStreamCreateWithFTPURL methods and accesses FTP remote directory list requests, and sent to ftp server;Step 2, in stream:handleEvent:Service end response is captured in callback method;Step 3, judged whether to successfully create CFReadStream streams according to the response of service end, if success, continues to judge whether static variable number is initial initialization value, be to exit judgement, otherwise create the n-th umber+1 level catalogues;If failure, and error code is 550, then recurrence judges forward, and new directory level is down created until finding to be present in after the directory level on ftp server.Such a method can solve the problems, such as that ftp server visit capacity is big in traditional determination methods, app execution efficiencys are low.
Description
Technical field
The invention belongs to FTP Technical Development Areas in iOS system, quickly sentence before more particularly to a kind of upload based on iOS
The method that disconnected FTP multistage directory paths whether there is.
Background technology
Under the big data epoch now, most of enterprise is transmitted and managed storage website all the elements using FTP
This mode.And staff's data that place can be had access on ftp server at any time for convenience, it is more next
More enterprises also gradually extends the function of carrying out FTP data transmission on mobile terminals.
FTP is File Transfer Protocol (FTP) English abbreviation, and Chinese is referred to as " text biography association
View ", the transmitted in both directions of the control file on Internet.Meanwhile it is also an application program (Application).
There are different FTP application programs based on different operating system, and all these application programs are in compliance with same agreement to pass
Defeated file.FTP's in use, user frequently encounters two concepts:" download " (Download) and " upload " (Upload)."
" file is exactly from distance host copied files to the computer of oneself for download;" upload " file be exactly by file from oneself
It is copied in computer on distance host.For Internet language, user can be remotely main to (from) by client program
Machine uploads (download) file.
Briefly, the server for supporting File Transfer Protocol is exactly ftp server.
With most of Internet services, FTP is also a client/server system.User passes through a branch
The client program of File Transfer Protocol is held, is connected to the ftp server program on distance host.User by client program to
Server program sends order, and server program performs the order that user is sent, and the result of execution is returned into client computer.
Such as user sends an order, it is desirable to which server transmits the copy of some file to user, and server can respond
This order, specified file is delivered on the machine of user.Client program represents user and receives this file, is deposited
In User Catalog.
FTP modes of operation based on iOS need to create server, a username received for FTP connections, and
Password initializer.Assume that you always need a username to be connected with password to establish FTP in terms of realization.
Apple Inc. provides the CFFTP in bottom frame CFNetwork to realize iOS FTP transmission operations, and CFFTP is used
CFReadStream transmits FTP data.For example asked using CFReadStreamCreateWithFTPURL methods to create FTP
Ask, can so create a CFReadStreamRef object simultaneously to read the data of ftp server transmission, then use
CFReadStreamSetClient methods set call back function to read the information that ftp server is responded, if the stream created is deposited
Just readStream is being added to the threading operation monitored in the run loop of program where the stream.If create loss to lose, just
Error message corresponding to being returned in callback method.
Existing method would generally first judge that the file to be uploaded is wanted before the FTP upload operations of some file are carried out
Whether the FTP multistages directory path of storage has been present, and is just directly uploaded if having, it's not true to be created, if not having
There is judgement just directly to upload, may be not present due to uploading certain one-level of FTP multistage catalogues in path, corresponding road can not be found
Footpath and the failure for causing upload operation.It is traditional at present to judge that the method that FTP multistage catalogues whether there is is (it is assumed that with one
Individual static variable i records the catalogue series currently judged, and 0) i initial value is:
(1) all catalogue list of file names on ftp server under i-stage are obtained, are put into a data source array;
(2) i-stage directory name folderName corresponding to multistage catalogue to be judged is obtained;
(3) a Bool variable is set, searching loop is carried out to array, if traversing, just jump identical with folderName
Go out circulation, it is yes to set Bool variables, is otherwise No;
(4) this grade of catalogue is judged whether according to Bool variables, in the absence of just directly creating the directory level, if existing
Continue to judgement i-th ++ all sub- level catalogues under level catalogue, repeat first step and judged;By that analogy.
Detailed process refers to Fig. 1, and its shortcoming is:Need to ask the remote directory on ftp server since the first order
List simultaneously carries out searching loop and compared, relatively complicated in operation, and adds the visit capacity of ftp server, app execution efficiencys
It is relatively low.
The content of the invention
The purpose of the present invention, it is to provide the determination methods that a kind of FTP multistage directory paths based on iOS whether there is,
It can solve the problems, such as that ftp server visit capacity is big in traditional determination methods, app execution efficiencys are low.
In order to reach above-mentioned purpose, solution of the invention is:
The determination methods that a kind of FTP multistage directory paths based on iOS whether there is, if the integer variable with static state
Number records the series of judged current directory, and initialization value is the series -1 for the multistage catalogue to be judged;
The determination methods comprise the following steps:
Step 1, multistage catalogue to be judged is spliced into the url for meeting FTP, passed through
CFReadStreamCreateWithFTPURL methods, which create, accesses FTP remote directory list requests, and sends to FTP service
Device;
Step 2, in stream:handleEvent:Service end response is captured in callback method;
Step 3, judged whether to successfully create commandStream streams according to the response of service end.
In above-mentioned steps 3, if being judged as creating successfully, continue to judge whether static variable number is initial initial
Change value, if the static variable number of current directory series is initial initialization value, judgement is exited, performs other operations;
If the static variable number of current directory series is not initial initialization value, the n-th umber+1 level catalogues are created.
In above-mentioned steps 3, if being judged as creating failure, error code is obtained by CFReadStreamGetError, if wrong
Error code is 550, then recurrence judges forward, until find be present in after the directory level on ftp server could down create it is new
Directory level.
The step of above-mentioned recurrence forward judges be:
A, the url for being spliced into FTP after last directory level of the multistage catalogue currently judged again is removed, while being used for
The static variable number for recording current directory series subtracts 1 certainly;
B, the url newly spliced is substituted into step 1, creates FTP requests, repeat step 1-3.
After such scheme, the present invention need not the catalogue to be judged to every one-level go ask ftp server on it is remote
Journey directory listing, avoid and ftp server remote directory list progress searching loop comparison is repeatedly accessed in traditional determination methods
Method, but by directly creating FTP requests to the multistage catalogue to be judged, the service end captured according to callback method is rung
It should make a decision, so as to reduce the access times to ftp server, further increase app execution efficiency, optimize app
Performance.
Brief description of the drawings
Fig. 1 is traditional method flow diagram that judges FTP multistage catalogues and whether there is;
Fig. 2 is the flow chart of the present invention.
Embodiment
Below with reference to accompanying drawing, technical scheme and beneficial effect are described in detail.
As shown in Fig. 2 the present invention provides the determination methods that a kind of FTP multistage directory paths based on iOS whether there is,
Being assumed first that when realizing always needs a username to be connected with password to establish FTP, and need one it is static whole
Type variable number records the series of judged current directory, and initialization value is the level for the multistage catalogue to be judged
Number -1 (if Array Bound occurs if being initialized as the series of multistage catalogue).
The determination methods comprise the following steps:
Step 1, FTP requests are created:Multistage catalogue to be judged directly is spliced into the url for meeting FTP by client, passes through
CFReadStreamCreateWithFTPURL methods, which create, accesses FTP remote directory list requests, and sends to FTP service
Device;
Step 2, in stream:handleEvent:Service end response is captured in callback method;
Step 3, judged whether to successfully create CFReadStream streams according to the response of service end, and according to following two feelings
Condition is respectively processed:
The first situation:Create successfully
Now need to continue to judge whether static variable number is initial initialization value, and be divided into two kinds of situations:
Situation 1, the static variable number of current directory series is initial initialization value, illustrates request for the first time just
Through successfully creating stream, i.e., the FTP multistage directory paths that uploaded have existed, have then exited judgement, perform other operations, such as
Upload operation can directly be carried out;
Situation 2, the static variable number of current directory series is not initial initialization value, i.e. static variable number
Change, just occurred result in static variable number without the situation of created directory level before explanation and change
(because having carried out static variable number from reducing in the callback method that stream creates failure), until in current this
Under directory level, CFReadStream streams can create success, illustrate that current directory level is existing on ftp server, but the
Number+1 directory levels are not present, thus need not again forward recurrence judge, it should start down create directory.
It should be noted herein:FTP directory creatings under iOS platforms use
CFWriteStreamCreateWithFTPURL functions are created, but can not disposably create multiple catalogues, are called every time
CFWriteStreamCreateWithFTPURL may only create a directory rank.
The first situation:Create failure
Error code is obtained by CFReadStreamGetError, if error code is 550 (Requested action not
Taken.File unavailable (e.g., file not found, no access)), illustrate that the multistage catalogue of the request exists
It is not present on ftp server, causes establishment loss to lose, but can not directly create this grade of catalogue, because it was assumed that above this grade of catalogue
Certain one-level is also not present, then it is also that establishment is unsuccessful directly to create current directory, so also needing to recurrence judgement forward, directly
To find be present in the directory level on ftp server after could down create new directory level;According to following steps recurrence forward
Judge:
A, the url for being spliced into FTP after last directory level of the multistage catalogue currently judged again is removed, while being used for
The static variable number for recording current directory series subtracts 1 certainly;
B, step 1 is returned to:The url newly spliced is created into FTP requests by step 1, and continues down to perform.
If error code is not 550, corresponding operating is carried out according to specific error code.
The technological thought of above example only to illustrate the invention, it is impossible to protection scope of the present invention is limited with this, it is every
According to technological thought proposed by the present invention, any change done on the basis of technical scheme, the scope of the present invention is each fallen within
Within.
Claims (4)
- A kind of 1. determination methods that FTP multistage directory paths based on iOS whether there is, it is characterised in that:If with the whole of static state Type variable number records the series of judged current directory, and initialization value is the level for the multistage catalogue to be judged Number -1;The determination methods comprise the following steps:Step 1, multistage catalogue to be judged is spliced into the url for meeting FTP, passed through CFReadStreamCreateWithFTPURL methods, which create, accesses FTP remote directory list requests, and sends to FTP service Device;Step 2, in stream:handleEvent:Service end response is captured in callback method;Step 3, judged whether to successfully create CFReadStream streams according to the response of service end.
- 2. the determination methods that a kind of FTP multistage directory paths based on iOS as claimed in claim 1 whether there is, its feature It is:In the step 3, successfully, continue to judge whether static variable number is initial initialization if being judged as creating Value, if the static variable number of current directory series is initial initialization value, exits judgement, performs other operations;If The static variable number of current directory series is not initial initialization value, then creates the n-th umber+1 level catalogues.
- 3. the determination methods that a kind of FTP multistage directory paths based on iOS as claimed in claim 1 whether there is, its feature It is:In the step 3, if being judged as creating failure, error code is obtained by CFReadStreamGetError, if error code 550, then forward recurrence judge, until find be present in the directory level on ftp server after could down create new catalogue Level.
- 4. the determination methods that a kind of FTP multistage directory paths based on iOS as claimed in claim 3 whether there is, its feature It is:The step of recurrence forward judges be:A, the url for being spliced into FTP after last directory level of the multistage catalogue currently judged again is removed, while being used for recording The static variable number of current directory series subtracts 1 certainly;B, the url newly spliced is substituted into step 1, creates FTP requests, repeat step 1-3.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710595277.7A CN107395719B (en) | 2017-07-20 | 2017-07-20 | iOS-based FTP multi-level directory path existence judging method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710595277.7A CN107395719B (en) | 2017-07-20 | 2017-07-20 | iOS-based FTP multi-level directory path existence judging method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107395719A true CN107395719A (en) | 2017-11-24 |
CN107395719B CN107395719B (en) | 2021-02-02 |
Family
ID=60336460
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710595277.7A Active CN107395719B (en) | 2017-07-20 | 2017-07-20 | iOS-based FTP multi-level directory path existence judging method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107395719B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103810011A (en) * | 2014-02-25 | 2014-05-21 | 广州视源电子科技股份有限公司 | Method for achieving OTA upgrading through file server |
US20150341426A1 (en) * | 2005-09-23 | 2015-11-26 | Samsung Electronics Co., Ltd. | Document distribution system and method using webdav protocol |
-
2017
- 2017-07-20 CN CN201710595277.7A patent/CN107395719B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20150341426A1 (en) * | 2005-09-23 | 2015-11-26 | Samsung Electronics Co., Ltd. | Document distribution system and method using webdav protocol |
CN103810011A (en) * | 2014-02-25 | 2014-05-21 | 广州视源电子科技股份有限公司 | Method for achieving OTA upgrading through file server |
Non-Patent Citations (1)
Title |
---|
ZHZHX0318: "C#获取FTP目录下文件夹、文件的方法,进而判断FTP下指定文件夹是否存在", 《HTTPS://WWW.CNBLOGS.COM/ZHZHX/P/3313691.HTML》 * |
Also Published As
Publication number | Publication date |
---|---|
CN107395719B (en) | 2021-02-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP6018182B2 (en) | Send category information | |
US8793379B2 (en) | System or method to automatically provision a storage volume by having an app-aware based appliance in a storage cloud environment | |
US9311326B2 (en) | Virtual file system for automated data replication and review | |
US8321503B2 (en) | Context-specific network resource addressing model for distributed services | |
US20150237113A1 (en) | Method and system for file transmission | |
CN109361754A (en) | A kind of document transmission method and device based on browser | |
CN110784528B (en) | File downloading method and device and storage medium | |
US9218428B2 (en) | Techniques for generating different sessions for multiple tabs of a single browser window | |
KR20200062373A (en) | System, method and computer-readable storage medium for customizable event-triggered computation at edge locations | |
WO2002029519A9 (en) | Systems and methods for supporting the delivery of streamed content | |
WO2014004308A1 (en) | Device, system, and method for client-governed session persistency between one or more clients and servers of a data center | |
US9529578B2 (en) | Automated service version upgrading | |
CN105812456A (en) | File transmission method and device | |
US8103631B2 (en) | Merging files on storage and retrieve | |
CN104247380A (en) | Binding crud-type protocols in distributed agreement protocols | |
CN113760278A (en) | Page management method and device | |
WO2010060766A1 (en) | System, device, method and computer-readable medium for providing network service information | |
US9819732B2 (en) | Methods for centralized management API service across disparate storage platforms and devices thereof | |
CN107395719A (en) | The determination methods that a kind of FTP multistage directory paths based on iOS whether there is | |
CN111031005A (en) | Js-based reverse proxy server and reverse proxy method | |
CN110300140B (en) | Method for updating content in cloud distribution network, refreshing client and network node | |
US20100185761A1 (en) | Service provider node, and computer-readable recording medium storing service provider program | |
CN114301929B (en) | Cloud clipboard data synchronization method and device, cloud server and system | |
EP1754145A1 (en) | Method and apparatus for supporting multiple versions of a web services protocol | |
CN103970794B (en) | Data access method and data access device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |