• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Freegle / iznik-server / 94448be2-6544-4c10-bf5b-b75ebdf270cf

13 Jun 2024 02:08PM UTC coverage: 94.815% (+0.009%) from 94.806%
94448be2-6544-4c10-bf5b-b75ebdf270cf

push

circleci

edwh
Uploadcare - event and volop images

8 of 9 new or added lines in 2 files covered. (88.89%)

1 existing line in 1 file now uncovered.

25437 of 26828 relevant lines covered (94.82%)

31.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

21.74
/include/misc/UploadCare.php
1
<?php
2
namespace Freegle\Iznik;
3

4
class UploadCare {
5
    private $config = NULL;
6
    private $fileApi = NULL;
7

8
    function __construct() {
9
        if (UPLOADCARE_PUBLIC_KEY) {
2✔
10
            $this->config = \Uploadcare\Configuration::create(UPLOADCARE_PUBLIC_KEY, UPLOADCARE_SECRET_KEY);
×
11
            $this->api = (new \Uploadcare\Api($this->config));
×
12
            $this->fileApi = $this->api->file();
×
13
            $this->uploaderApi = $this->api->uploader();
×
14
        }
15
    }
16

17
    function stripExif($uid) {
18
        $oldFileInfo = $this->fileApi->fileInfo($uid);
×
19

20
        # We want to strip the EXIF data.  We remove all of it to avoid any privacy issues.  You have to
21
        # add preview as an operation to make it work.
22
        #
23
        # syncUploadFromUrl guarantees that the image is available on the CDN before returning.
24
        $newFileInfo = $this->uploaderApi->syncUploadFromUrl(UPLOADCARE_CDN . "$uid/-/strip_meta/all/-/preview/");
×
25
        $newuid = $newFileInfo->getUuid();
×
26
        $this->fileApi->storeFile($newuid);
×
27
        #error_log("Copy $uid, $url to $newuid, $newurl, ready " . $newFileInfo->isReady());
28

29
        if ($newuid) {
×
30
            $this->fileApi->deleteFile($oldFileInfo);
×
31
        }
32

33
        return $newuid;
×
34
    }
35

36
    function getPerceptualHash($uid) {
37
        $json  = file_get_contents(UPLOADCARE_CDN . "$uid/-/json/");
×
38

39
        if ($json) {
×
40
            $data = json_decode($json, true);
×
41
            return $data['hash'];
×
42
        }
43

44
        return NULL;
×
45
    }
46

47
    function getUrl($uid, $mods) {
48
        # Construct the external URL from the UID and mods.
49
        $url = UPLOADCARE_CDN . "$uid/";
2✔
50
        $mods = json_decode($mods, TRUE);
2✔
51

52
        if ($mods) {
2✔
53
            foreach ($mods as $mod => $val) {
×
NEW
54
                $url .= "-/$mod/$val/";
×
55
            }
56
        }
57

58
        return $url;
2✔
59
    }
60
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc