mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 05:07:51 +08:00
new backend: zoho workdrive - fixes #4533
This commit is contained in:
parent
62c9074132
commit
66c3f2f31f
|
@ -69,6 +69,7 @@ Rclone *("rsync for cloud storage")* is a command line program to sync files and
|
|||
* Wasabi [:page_facing_up:](https://rclone.org/s3/#wasabi)
|
||||
* WebDAV [:page_facing_up:](https://rclone.org/webdav/)
|
||||
* Yandex Disk [:page_facing_up:](https://rclone.org/yandex/)
|
||||
* Zoho WorkDrive [:page_facing_up:](https://rclone.org/zoho/)
|
||||
* The local filesystem [:page_facing_up:](https://rclone.org/local/)
|
||||
|
||||
Please see [the full list of all storage providers and their features](https://rclone.org/overview/)
|
||||
|
|
|
@ -42,4 +42,5 @@ import (
|
|||
_ "github.com/rclone/rclone/backend/union"
|
||||
_ "github.com/rclone/rclone/backend/webdav"
|
||||
_ "github.com/rclone/rclone/backend/yandex"
|
||||
_ "github.com/rclone/rclone/backend/zoho"
|
||||
)
|
||||
|
|
118
backend/zoho/api/types.go
Normal file
118
backend/zoho/api/types.go
Normal file
|
@ -0,0 +1,118 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Time represents represents date and time information for Zoho
|
||||
// Zoho uses milliseconds since unix epoch (Java currentTimeMillis)
|
||||
type Time time.Time
|
||||
|
||||
// UnmarshalJSON turns JSON into a Time
|
||||
func (t *Time) UnmarshalJSON(data []byte) error {
|
||||
millis, err := strconv.ParseInt(string(data), 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*t = Time(time.Unix(0, millis*int64(time.Millisecond)))
|
||||
return nil
|
||||
}
|
||||
|
||||
// User is a Zoho user we are only interested in the ZUID here
|
||||
type User struct {
|
||||
FirstName string `json:"First_Name"`
|
||||
Email string `json:"Email"`
|
||||
LastName string `json:"Last_Name"`
|
||||
DisplayName string `json:"Display_Name"`
|
||||
ZUID int64 `json:"ZUID"`
|
||||
}
|
||||
|
||||
// TeamWorkspace represents a Zoho Team or workspace
|
||||
// It's actually a VERY large json object that differs between
|
||||
// Team and Workspace but we are only interested in some fields
|
||||
// that both of them have so we can use the same struct for both
|
||||
type TeamWorkspace struct {
|
||||
ID string `json:"id"`
|
||||
Attributes struct {
|
||||
Name string `json:"name"`
|
||||
Created Time `json:"created_time_in_millisecond"`
|
||||
IsPart bool `json:"is_partof"`
|
||||
} `json:"attributes"`
|
||||
}
|
||||
|
||||
// TeamWorkspaceResponse is the response by the list teams api
|
||||
type TeamWorkspaceResponse struct {
|
||||
TeamWorkspace []TeamWorkspace `json:"data"`
|
||||
}
|
||||
|
||||
// Item is may represent a file or a folder in Zoho Workdrive
|
||||
type Item struct {
|
||||
ID string `json:"id"`
|
||||
Attributes struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
IsFolder bool `json:"is_folder"`
|
||||
CreatedTime Time `json:"created_time_in_millisecond"`
|
||||
ModifiedTime Time `json:"modified_time_in_millisecond"`
|
||||
UploadedTime Time `json:"uploaded_time_in_millisecond"`
|
||||
StorageInfo struct {
|
||||
Size int64 `json:"size_in_bytes"`
|
||||
FileCount int64 `json:"files_count"`
|
||||
FolderCount int64 `json:"folders_count"`
|
||||
} `json:"storage_info"`
|
||||
} `json:"attributes"`
|
||||
}
|
||||
|
||||
// ItemInfo contains a single Zoho Item
|
||||
type ItemInfo struct {
|
||||
Item Item `json:"data"`
|
||||
}
|
||||
|
||||
// ItemList contains multiple Zoho Items
|
||||
type ItemList struct {
|
||||
Items []Item `json:"data"`
|
||||
}
|
||||
|
||||
// UploadInfo is a simplified and slightly different version of
|
||||
// the Item struct only used in the response to uploads
|
||||
type UploadInfo struct {
|
||||
Attributes struct {
|
||||
ParentID string `json:"parent_id"`
|
||||
FileName string `json:"notes.txt"`
|
||||
RessourceID string `json:"resource_id"`
|
||||
} `json:"attributes"`
|
||||
}
|
||||
|
||||
// UploadResponse is the response to a file Upload
|
||||
type UploadResponse struct {
|
||||
Uploads []UploadInfo `json:"data"`
|
||||
}
|
||||
|
||||
// WriteMetadataRequest is is used to write metadata for a
|
||||
// single item
|
||||
type WriteMetadataRequest struct {
|
||||
Data WriteMetadata `json:"data"`
|
||||
}
|
||||
|
||||
// WriteMultiMetadataRequest can be used to write metadata for
|
||||
// multiple items at once but we don't use it that way
|
||||
type WriteMultiMetadataRequest struct {
|
||||
Meta []WriteMetadata `json:"data"`
|
||||
}
|
||||
|
||||
// WriteMetadata is used to write item metadata
|
||||
type WriteMetadata struct {
|
||||
Attributes WriteAttributes `json:"attributes,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
// WriteAttributes is used to set various attributes for on items
|
||||
// this is used for Move, Copy, Delete, Rename
|
||||
type WriteAttributes struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
ParentID string `json:"parent_id,omitempty"`
|
||||
RessourceID string `json:"resource_id,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
}
|
1270
backend/zoho/zoho.go
Normal file
1270
backend/zoho/zoho.go
Normal file
File diff suppressed because it is too large
Load Diff
17
backend/zoho/zoho_test.go
Normal file
17
backend/zoho/zoho_test.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Test Zoho filesystem interface
|
||||
package zoho_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/rclone/rclone/backend/zoho"
|
||||
"github.com/rclone/rclone/fstest/fstests"
|
||||
)
|
||||
|
||||
// TestIntegration runs integration tests against the remote
|
||||
func TestIntegration(t *testing.T) {
|
||||
fstests.Run(t, &fstests.Opt{
|
||||
RemoteName: "TestZoho:",
|
||||
NilObject: (*zoho.Object)(nil),
|
||||
})
|
||||
}
|
|
@ -64,6 +64,7 @@ docs = [
|
|||
"union.md",
|
||||
"webdav.md",
|
||||
"yandex.md",
|
||||
"zoho.md",
|
||||
|
||||
"local.md",
|
||||
"changelog.md",
|
||||
|
|
|
@ -154,6 +154,7 @@ WebDAV or S3, that work out of the box.)
|
|||
{{< provider name="Wasabi" home="https://wasabi.com/" config="/s3/#wasabi" >}}
|
||||
{{< provider name="WebDAV" home="https://en.wikipedia.org/wiki/WebDAV" config="/webdav/" >}}
|
||||
{{< provider name="Yandex Disk" home="https://disk.yandex.com/" config="/yandex/" >}}
|
||||
{{< provider name="Zoho WorkDrive" home="https://www.zoho.com/workdrive/" config="/zoho/" >}}
|
||||
{{< provider name="The local filesystem" home="/local/" config="/local/" end="true">}}
|
||||
{{< /provider_list >}}
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ See the following for detailed instructions for
|
|||
* [Union](/union/)
|
||||
* [WebDAV](/webdav/)
|
||||
* [Yandex Disk](/yandex/)
|
||||
* [Zoho WorkDrive](/zoho/)
|
||||
* [The local filesystem](/local/)
|
||||
|
||||
Usage
|
||||
|
|
|
@ -49,6 +49,7 @@ Here is an overview of the major features of each cloud storage system.
|
|||
| Tardigrade | - | Yes | No | No | - |
|
||||
| WebDAV | MD5, SHA1 ³ | Yes ⁴ | Depends | No | - |
|
||||
| Yandex Disk | MD5 | Yes | No | No | R |
|
||||
| Zoho WorkDrive | - | No | No | No | - |
|
||||
| The local filesystem | All | Yes | Depends | No | - |
|
||||
|
||||
### Notes
|
||||
|
@ -360,6 +361,7 @@ upon backend specific capabilities.
|
|||
| Tardigrade | Yes † | No | No | No | No | Yes | Yes | No | No | No |
|
||||
| WebDAV | Yes | Yes | Yes | Yes | No | No | Yes ‡ | No [#2178](https://github.com/rclone/rclone/issues/2178) | Yes | Yes |
|
||||
| Yandex Disk | Yes | Yes | Yes | Yes | Yes | No | Yes | Yes | Yes | Yes |
|
||||
| Zoho WorkDrive | Yes | Yes | Yes | Yes | No | No | No | No | Yes | Yes |
|
||||
| The local filesystem | Yes | No | Yes | Yes | No | No | Yes | No | Yes | Yes |
|
||||
|
||||
### Purge ###
|
||||
|
|
194
docs/content/zoho.md
Normal file
194
docs/content/zoho.md
Normal file
|
@ -0,0 +1,194 @@
|
|||
---
|
||||
title: "Zoho"
|
||||
description: "Zoho WorkDrive"
|
||||
---
|
||||
|
||||
{{< icon "fas fa-folder" >}}Zoho Workdrive
|
||||
----------------------------------------
|
||||
|
||||
[Zoho WorkDrive](https://www.zoho.com/workdrive/) is a cloud storage solution created by [Zoho](https://zoho.com).
|
||||
|
||||
Here is an example of making a zoho configuration. First run
|
||||
|
||||
rclone config
|
||||
|
||||
This will guide you through an interactive setup process:
|
||||
|
||||
```
|
||||
No remotes found - make a new one
|
||||
n) New remote
|
||||
s) Set configuration password
|
||||
n/s> n
|
||||
name> remote
|
||||
Type of storage to configure.
|
||||
Enter a string value. Press Enter for the default ("").
|
||||
Choose a number from below, or type in your own value
|
||||
[snip]
|
||||
XX / Zoho
|
||||
\ "zoho"
|
||||
[snip]
|
||||
Storage> zoho
|
||||
** See help for zoho backend at: https://rclone.org/zoho/ **
|
||||
|
||||
OAuth Client Id
|
||||
Leave blank normally.
|
||||
Enter a string value. Press Enter for the default ("").
|
||||
client_id>
|
||||
OAuth Client Secret
|
||||
Leave blank normally.
|
||||
Enter a string value. Press Enter for the default ("").
|
||||
client_secret>
|
||||
Edit advanced config? (y/n)
|
||||
y) Yes
|
||||
n) No (default)
|
||||
y/n> n
|
||||
Remote config
|
||||
Use auto config?
|
||||
* Say Y if not sure
|
||||
* Say N if you are working on a remote or headless machine
|
||||
y) Yes (default)
|
||||
n) No
|
||||
y/n>
|
||||
If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=LVn0IHzxej1ZkmQw31d0wQ
|
||||
Log in and authorize rclone for access
|
||||
Waiting for code...
|
||||
Got code
|
||||
Choose a number from below, or type in your own value
|
||||
1 / MyTeam
|
||||
\ "4u28602177065ff22426787a6745dba8954eb"
|
||||
Enter a Team ID> 1
|
||||
Choose a number from below, or type in your own value
|
||||
1 / General
|
||||
\ "4u2869d2aa6fca04f4f2f896b6539243b85b1"
|
||||
Enter a Workspace ID> 1
|
||||
--------------------
|
||||
[remote]
|
||||
type = zoho
|
||||
token = {"access_token":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","token_type":"Zoho-oauthtoken","refresh_token":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","expiry":"2020-10-12T00:54:52.370275223+02:00"}
|
||||
root_folder_id = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
--------------------
|
||||
y) Yes this is OK (default)
|
||||
e) Edit this remote
|
||||
d) Delete this remote
|
||||
y/e/d>
|
||||
```
|
||||
|
||||
See the [remote setup docs](/remote_setup/) for how to set it up on a
|
||||
machine with no Internet browser available.
|
||||
|
||||
Note that rclone runs a webserver on your local machine to collect the
|
||||
token as returned from Zoho Workdrive. This only runs from the moment it
|
||||
opens your browser to the moment you get back the verification code.
|
||||
This is on `http://127.0.0.1:53682/` and this it may require you to
|
||||
unblock it temporarily if you are running a host firewall.
|
||||
|
||||
Once configured you can then use `rclone` like this,
|
||||
|
||||
See top level directories
|
||||
|
||||
rclone lsd remote:
|
||||
|
||||
Make a new directory
|
||||
|
||||
rclone mkdir remote:directory
|
||||
|
||||
List the contents of a directory
|
||||
|
||||
rclone ls remote:directory
|
||||
|
||||
Sync `/home/local/directory` to the remote path, deleting any
|
||||
excess files in the path.
|
||||
|
||||
rclone sync -i /home/local/directory remote:directory
|
||||
|
||||
Zoho paths may be as deep as required, eg `remote:directory/subdirectory`.
|
||||
|
||||
### Modified time ###
|
||||
|
||||
Modified times are currently not supported for Zoho Workdrive
|
||||
|
||||
### Checksums ###
|
||||
|
||||
No checksums are supported.
|
||||
|
||||
### Usage information ###
|
||||
|
||||
To view your current quota you can use the `rclone about remote:`
|
||||
command which will display your current usage.
|
||||
|
||||
#### Restricted filename characters
|
||||
|
||||
Only control characters and invalid UTF-8 are replaced. In addition most
|
||||
Unicode full-width characters are not supported at all and will be removed
|
||||
from filenames during upload.
|
||||
|
||||
{{< rem autogenerated options start" - DO NOT EDIT - instead edit fs.RegInfo in backend/zoho/zoho.go then run make backenddocs" >}}
|
||||
### Standard Options
|
||||
|
||||
Here are the standard options specific to zoho (Zoho).
|
||||
|
||||
#### --zoho-client-id
|
||||
|
||||
OAuth Client Id
|
||||
Leave blank normally.
|
||||
|
||||
- Config: client_id
|
||||
- Env Var: RCLONE_ZOHO_CLIENT_ID
|
||||
- Type: string
|
||||
- Default: ""
|
||||
|
||||
#### --zoho-client-secret
|
||||
|
||||
OAuth Client Secret
|
||||
Leave blank normally.
|
||||
|
||||
- Config: client_secret
|
||||
- Env Var: RCLONE_ZOHO_CLIENT_SECRET
|
||||
- Type: string
|
||||
- Default: ""
|
||||
|
||||
### Advanced Options
|
||||
|
||||
Here are the advanced options specific to zoho (Zoho).
|
||||
|
||||
#### --zoho-token
|
||||
|
||||
OAuth Access Token as a JSON blob.
|
||||
|
||||
- Config: token
|
||||
- Env Var: RCLONE_ZOHO_TOKEN
|
||||
- Type: string
|
||||
- Default: ""
|
||||
|
||||
#### --zoho-auth-url
|
||||
|
||||
Auth server URL.
|
||||
Leave blank to use the provider defaults.
|
||||
|
||||
- Config: auth_url
|
||||
- Env Var: RCLONE_ZOHO_AUTH_URL
|
||||
- Type: string
|
||||
- Default: ""
|
||||
|
||||
#### --zoho-token-url
|
||||
|
||||
Token server url.
|
||||
Leave blank to use the provider defaults.
|
||||
|
||||
- Config: token_url
|
||||
- Env Var: RCLONE_ZOHO_TOKEN_URL
|
||||
- Type: string
|
||||
- Default: ""
|
||||
|
||||
#### --zoho-encoding
|
||||
|
||||
This sets the encoding for the backend.
|
||||
|
||||
See: the [encoding section in the overview](/overview/#encoding) for more info.
|
||||
|
||||
- Config: encoding
|
||||
- Env Var: RCLONE_ZOHO_ENCODING
|
||||
- Type: MultiEncoder
|
||||
- Default: Del,Ctl,InvalidUtf8
|
||||
|
||||
{{< rem autogenerated options stop >}}
|
|
@ -100,6 +100,7 @@
|
|||
<a class="dropdown-item" href="/union/"><i class="fa fa-link"></i> Union (merge backends)</a>
|
||||
<a class="dropdown-item" href="/webdav/"><i class="fa fa-server"></i> WebDAV</a>
|
||||
<a class="dropdown-item" href="/yandex/"><i class="fa fa-space-shuttle"></i> Yandex Disk</a>
|
||||
<a class="dropdown-item" href="/zoho/"><i class="fas fa-folder"></i> Zoho WorkDrive</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="/local/"><i class="fas fa-hdd"></i> The local filesystem</a>
|
||||
</div>
|
||||
|
|
|
@ -294,3 +294,6 @@ backends:
|
|||
- backend: "tardigrade"
|
||||
remote: "TestTardigrade:"
|
||||
fastlist: true
|
||||
- backend: "zoho"
|
||||
remote: "TestZoho:"
|
||||
fastlist: false
|
||||
|
|
Loading…
Reference in New Issue
Block a user