added revalidate cache feature
This commit is contained in:
@@ -28,6 +28,19 @@ type bulkIdResponseDto struct {
|
||||
Success bool `json:"success"`
|
||||
}
|
||||
|
||||
type assetBulkUploadCheckItem struct {
|
||||
Checksum string `json:"checksum"`
|
||||
Id string `json:"id"` // Not the assetID. Just a arbitrarily id string
|
||||
}
|
||||
|
||||
type assetBulkUploadCheckResult struct {
|
||||
Action string // can be "accept" or "reject"
|
||||
AssetId string
|
||||
Id string // Not the assetID. Just a arbitrary id string
|
||||
IsTrashed bool
|
||||
Reason string // can be "duplicate" or "unsupportedFormat" (i don't know what they mean by this)
|
||||
}
|
||||
|
||||
type APIKeyTransport struct {
|
||||
APIKey string
|
||||
}
|
||||
@@ -163,3 +176,38 @@ func addAssetsToAlbum(assets []string, album, baseURL string, httpClient http.Cl
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func bulkCheckAssets(assets []assetBulkUploadCheckItem, baseURL string, httpClient http.Client) ([]assetBulkUploadCheckResult, error) {
|
||||
body, _ := json.Marshal(struct {
|
||||
Assets []assetBulkUploadCheckItem `json:"assets"`
|
||||
}{Assets: assets})
|
||||
|
||||
req, err := http.NewRequest("POST", fmt.Sprintf("%s/api/assets/bulk-upload-check", baseURL), bytes.NewBuffer(body))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Accept", "application/json")
|
||||
|
||||
res, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer res.Body.Close()
|
||||
|
||||
respBody, _ := io.ReadAll(res.Body)
|
||||
if res.StatusCode != 200 {
|
||||
return nil, fmt.Errorf("buck check assets %d - %s ", res.StatusCode, string(respBody))
|
||||
}
|
||||
|
||||
var result struct {
|
||||
Results []assetBulkUploadCheckResult `json:"results"`
|
||||
}
|
||||
if err := json.Unmarshal(respBody, &result); err != nil {
|
||||
return nil, fmt.Errorf("parse immich response: %s", err)
|
||||
}
|
||||
|
||||
return result.Results, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user