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

Freegle / iznik-server / 2e982f03-a250-43d3-a894-4819c5574e24

03 Jun 2024 04:37PM UTC coverage: 94.863% (-0.006%) from 94.869%
2e982f03-a250-43d3-a894-4819c5574e24

push

circleci

edwh
Test fixes.

25429 of 26806 relevant lines covered (94.86%)

31.54 hits per line

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

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

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

8

9
    function __construct() {
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
    function stripExif($uid, $url) {
17
        $oldFileInfo = $this->fileApi->fileInfo($uid);
×
18

19
        # We want to strip the EXIF data.  We remove all of it to avoid any privacy issues.  You have to
20
        # add preview as an operation to make it work.
21
        #
22
        # syncUploadFromUrl guarantees that the image is available on the CDN before returning.
23
        $newFileInfo = $this->uploaderApi->syncUploadFromUrl("https://ucarecdn.com/$uid/-/strip_meta/all/-/preview/");
×
24
        $newuid = $newFileInfo->getUuid();
×
25
        $newurl = $newFileInfo->getOriginalFileUrl();
×
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, $newurl ];
×
34
    }
35

36
    function getPerceptualHash($uid) {
37
        $json  = file_get_contents("https://ucarecdn.com/$uid/-/json/");
×
38

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

44
        return NULL;
×
45
    }
46
}
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