2020-04-07 10:42:42 +02:00
|
|
|
/*
|
|
|
|
Package remote implements a remote service abstraction.
|
|
|
|
|
|
|
|
Additional information can be found in our Developer Guide:
|
|
|
|
|
|
|
|
https://github.com/photoprism/photoprism/wiki
|
2020-04-13 11:26:53 +02:00
|
|
|
|
|
|
|
See also:
|
|
|
|
- RClone (https://rclone.org/), a popular Go tool for syncing data with remote services
|
2020-04-07 10:42:42 +02:00
|
|
|
*/
|
|
|
|
package remote
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2020-04-24 14:11:17 +02:00
|
|
|
"time"
|
2020-04-07 10:42:42 +02:00
|
|
|
)
|
|
|
|
|
2020-04-24 14:11:17 +02:00
|
|
|
var client = &http.Client{Timeout: 30 * time.Second} // TODO: Change timeout if needed
|
2020-04-07 10:42:42 +02:00
|
|
|
|
|
|
|
const (
|
|
|
|
ServiceWebDAV = "webdav"
|
|
|
|
ServiceFacebook = "facebook"
|
|
|
|
ServiceTwitter = "twitter"
|
|
|
|
ServiceFlickr = "flickr"
|
|
|
|
ServiceInstagram = "instagram"
|
|
|
|
ServiceEyeEm = "eyeem"
|
|
|
|
ServiceTelegram = "telegram"
|
|
|
|
ServiceWhatsApp = "whatsapp"
|
|
|
|
ServiceGPhotos = "gphotos"
|
|
|
|
ServiceGDrive = "gdrive"
|
|
|
|
ServiceOneDrive = "onedrive"
|
|
|
|
)
|
|
|
|
|
|
|
|
func HttpOk(method, rawUrl string) bool {
|
|
|
|
req, err := http.NewRequest(method, rawUrl, nil)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if resp, err := client.Do(req); err != nil {
|
|
|
|
return false
|
|
|
|
} else if resp.StatusCode < 400 {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|