Read Barcode from Aspose Cloud Storage

@param string $remoteImageName Name of the remote image.
@param string $remoteFolder Name of the folder.
@param string $readType Type to read barcode.

@return array
@throws Exception
518540
public function readR($remoteImageName, $remoteFolder, $readType)
    {
        $uri = $this->uriBuilder($remoteImageName, $remoteFolder, $readType);
        $signedURI = Utils::sign($uri);

        $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
        $json = json_decode($responseStream);
        return $json->Barcodes;
    }
964819
public function readWithChecksum($symbology, $checksumValidation)
    {
        if ($symbology == '')
            throw new Exception('Symbology not specified');

        if ($checksumValidation == '')
            throw new Exception('Checksum not specified');

        //build URI to read barcode
        $strURI = Product::$baseProductUri . '/barcode/' . $this->getFileName() . '/recognize?type=' . $symbology . '&checksumValidation=' . $checksumValidation;

        //sign URI
        $signedURI = Utils::sign($strURI);

        $responseStream = Utils::processCommand($signedURI, 'GET', '', '');

        $json = json_decode($responseStream);

        if ($json->Code == 200)
            return $json->Barcodes;
        else
            return false;
    }
1011804
private byte[] readImage(String uriWithParams) {

        try {
            String pathAndQuery = OpenCms.getLinkManager().getRootPath(m_cms, uriWithParams);
            URI uri = new URI(pathAndQuery);
            String path = uri.getPath();
            String query = uri.getQuery();
            String scaleParams = null;
            if (query != null) {
                Matcher matcher = SCALE_PARAMS_PATTERN.matcher(query);
                if (matcher.find()) {
                    scaleParams = matcher.group(1);
                }
            }
            CmsFile imageFile = m_rootCms.readFile(path);
            byte[] result = imageFile.getContents();
            if (scaleParams != null) {
                CmsImageScaler scaler = new CmsImageScaler(scaleParams);
                result = scaler.scaleImage(imageFile);
            }
            return result;
        } catch (Exception e) {
            LOG.error("Problem with reading image " + uriWithParams + ": " + e.getLocalizedMessage(), e);
            return null;
        }
    }
1336255
public function toArray($filePath = null, string $disk = null, string $readerType = null): array
    {
        $filePath = $this->getFilePath($filePath);

        return $this->getImporter()->toArray(
            $this,
            $filePath,
            $disk ?? $this->disk ?? null,
            $readerType ?? $this->readerType ?? null
        );
    }
1332649
public function getSize(string $remoteFile)
    {
        $size = @ftp_size($this->ftp, $remoteFile);

        if ($size == -1) {
            throw new Exception("Cannot get file size");
        }

        return $size;
    }
152341
public static void runExample(AdWordsServicesInterface adWordsServices, AdWordsSession session)
      throws RemoteException {
    // Get the AdGroupAdService.
    AssetServiceInterface assetService = adWordsServices.get(session, AssetServiceInterface.class);

    int offset = 0;
    boolean morePages = true;

    // Create the selector.
    SelectorBuilder builder = new SelectorBuilder();
    Selector selector =
        builder
            .fields(
                AssetField.AssetName,
                AssetField.AssetStatus,
                AssetField.ImageFileSize,
                AssetField.ImageWidth,
                AssetField.ImageHeight,
                AssetField.ImageFullSizeUrl)
            .offset(offset)
            .limit(PAGE_SIZE)
            // Filter for image assets only.
            .equals(AssetField.AssetSubtype, AssetType.IMAGE.getValue())
            .build();

    int totalEntries = 0;
    while (morePages) {
      // Get the image assets.
      AssetPage page = assetService.get(selector);

      // Display the results.
      if (page.getEntries() != null && page.getEntries().length > 0) {
        totalEntries = page.getTotalNumEntries();
        int i = selector.getPaging().getStartIndex();
        for (Asset asset : page.getEntries()) {
          System.out.printf(
              "%d) Image asset with ID %d, name '%s', and status '%s' was found.%n",
              i, asset.getAssetId(), asset.getAssetName(), asset.getAssetStatus());
        }
      }

      offset += PAGE_SIZE;
      selector = builder.increaseOffsetBy(PAGE_SIZE).build();
      morePages = offset < page.getTotalNumEntries();
    }

    System.out.printf("Found %d image assets.%n", totalEntries);
  }
197328
public void get(String remoteFiles[], String localTargetDirectory) throws IOException {
        Session sess = null;

        if ((remoteFiles == null) || (localTargetDirectory == null))
            throw new IllegalArgumentException("Null argument.");

        if (remoteFiles.length == 0)
            return;

//        String cmd = "scp -f -r";
        String cmd = "scp -f ";

        for (int i = 0; i < remoteFiles.length; i++) {
            if (remoteFiles[i] == null)
                throw new IllegalArgumentException("Cannot accept null filename.");

            cmd += (" " + remoteFiles[i]);
        }

        try {
            sess = conn.openSession();
            sess.execCommand(cmd);
            receiveFiles(sess, remoteFiles, localTargetDirectory);
            sess.close();
        } catch (IOException e) {
            if (sess != null)
                sess.close();

            throw (IOException) new IOException("Error during SCP transfer.").initCause(e);
        }
    }
109708
@Override
    public void readExternalEntry(@NotNull Bytes source, byte remoteNodeIdentifier) {
        byte hunk = source.readByte();
        if (hunk == BOOTSTRAP_TIME_HUNK) {
            setRemoteNodeCouldBootstrapFrom(remoteNodeIdentifier, source.readLong());
        } else {
            assert hunk == ENTRY_HUNK;
            try (CompiledReplicatedMapQueryContext<K, V, R> remoteOpContext = mapContext()) {
                remoteOpContext.processReplicatedEvent(remoteNodeIdentifier, source);
            }
        }
    }
797340
public function readSpecificRegion($symbology, $rectX, $rectY, $rectWidth, $rectHeight)
    {
        if ($symbology == '')
            throw new Exception('Symbology not specified');

        if ($rectX == '')
            throw new Exception('X position not specified');

        if ($rectY == '')
            throw new Exception('Y position not specified');

        if ($rectWidth == '')
            throw new Exception('Width not specified');

        if ($rectHeight == '')
            throw new Exception('Height not specified');

        //build URI to read barcode
        $strURI = Product::$baseProductUri . '/barcode/' . $this->getFileName() . '/recognize?type=' . $symbology . '&rectX=' . $rectX . '&rectY=' . $rectY
            . '&rectWidth=' . $rectWidth . '&rectHeight=' . $rectHeight;

        //sign URI
        $signedURI = Utils::sign($strURI);

        $responseStream = Utils::processCommand($signedURI, 'GET', '', '');

        $json = json_decode($responseStream);

        if ($json->Code == 200)
            return $json->Barcodes;
        else
            return false;
    }
1151897
public function downloadRemoteSource($src)
    {
        if (!$this->isRemoteSourceOnWhitelist($src)) {
            throw new Exception("Hostname is not on whitelist for remote sources.");
        }

        $remote = new CRemoteImage();

        if (!is_writable($this->remoteCache)) {
            $this->log("The remote cache is not writable.");
        }

        $remote->setCache($this->remoteCache);
        $remote->useCache($this->useCache);
        $src = $remote->download($src);

        $this->log("Remote HTTP status: " . $remote->getStatus());
        $this->log("Remote item is in local cache: $src");
        $this->log("Remote details on cache:" . print_r($remote->getDetails(), true));

        return $src;
    }
816951
public static ImageReader getImageReader(final Object sourceImage) throws IOException {

        ImageInputStream imageInputStream = ImageIO.createImageInputStream(sourceImage);
        Iterator<ImageReader> imageReaders = ImageIO.getImageReaders(imageInputStream);
        ImageReader destinationImageReader = null;
        if (imageReaders.hasNext()) {
            destinationImageReader = imageReaders.next();
            setImageReaderHaveInputStream(destinationImageReader, imageInputStream);
        }
        return destinationImageReader;
    }
1038944
public function serializeImageToJson(JsonSerializationVisitor $visitor, Image $image, array $type, Context $context)
    {
        $type['name'] = 'array';

        return $visitor->visitArray([
            'id' => $image->getId(),
            'url' => $this->imageManager->filePathToWebPath($image->getPath())
        ], $type, $context);
    }
107715
private function download(RemotePackageEntity $remotePackage)
    {
        $temp = $this->app->make(VolatileDirectory::class);
        /* @var VolatileDirectory $temp */
        $zipFilename = $temp->getPath() . '/downloaded.zip';
        $this->httpClient->reset();
        $this->httpClient->setOptions([
            'storeresponse' => false,
            'outputstream' => $zipFilename,
        ]);
        $request = new Request();

        if (($header = (string) getenv('CT_REMOTEPACKAGE_HEADER')) &&
            $value = (string) getenv('CT_REMOTEPACKAGE_HEADER_VALUE')) {
            $request->getHeaders()->addHeaderLine($header, $value);
        }
        $request->setMethod('GET')->setUri($remotePackage->getArchiveUrl());
        $response = $this->httpClient->send($request);
        $this->httpClient->reset();
        $streamHandle = ($response instanceof \Zend\Http\Response\Stream) ? $response->getStream() : null;
        if (is_resource($streamHandle)) {
            fclose($streamHandle);
        }
        if ($response->getStatusCode() != 200) {
            $error = t('Failed to download package archive %s v%s: %s (%d)', $remotePackage->getHandle(), $remotePackage->getVersion(), $response->getReasonPhrase(), $response->getStatusCode());
            unset($temp);
            throw new DownloadException($error, $response->getStatusCode());
        }

        $contentEncodingHeader = $response->getHeaders()->get('Content-Encoding');
        if (!empty($contentEncodingHeader)) {
            $contentEncoding = trim((string) $contentEncodingHeader->getFieldValue());
            if ($contentEncoding !== '') {
                $decodedZipFilename = $temp->getPath() . '/downloaded-decoded.zip';
                switch (strtolower($contentEncoding)) {
                    case 'gzip':
                        $this->decodeGzip($zipFilename, $decodedZipFilename);
                        break;
                    case 'deflate':
                        $this->decodeDeflate($zipFilename, $decodedZipFilename);
                        break;
                    case 'plainbinary':
                    default:
                        $decodedZipFilename = '';
                        break;
                }
                if ($decodedZipFilename !== '') {
                    $temp->getFilesystem()->delete([$zipFilename]);
                    $zipFilename = $decodedZipFilename;
                }
            }
        }

        $temp->getFilesystem()->makeDirectory($temp->getPath() . '/unzipped');
        $this->zip->unzip($zipFilename, $temp->getPath() . '/unzipped');
        $temp->getFilesystem()->delete([$zipFilename]);

        return $temp;
    }
194086
@Override
	public void setReadOnly(boolean readOnly) throws RemoteException {
		if (this.readOnly != readOnly) {
			tx.commit();
			this.readOnly = readOnly;
			try {
				tx = VanillaDb.txMgr().newTransaction(isolationLevel, readOnly);
			} catch (Exception e) {
				throw new RemoteException("error creating transaction ", e);
			}
		}
	}
755534
public function getRepositoryPermission($uri, $recipientUri)
    {
        $url = $this->service_url . '/permissions' . $uri;
        $url .= ";recipient=" . str_replace('/', '%2F', $recipientUri);
        $data = $this->service->prepAndSend($url, array(200), 'GET', null, true);
        return RepositoryPermission::createFromJSON($data);
    }
118570
public void get(String remoteFileName,
                    DataSink sink,
                    MarkerListener mListener)
        throws IOException, ClientException, ServerException {
        checkTransferParamsGet();

        localServer.store(sink);
        controlChannel.write(new Command("RETR", remoteFileName));

        transferRunSingleThread(localServer.getControlChannel(), mListener);
    }
182258
public function readDocument(TransferInterface $transfer, $containerName)
    {
        $this->checkTransferMethods($transfer);

        $fileName = $transfer->getFileName();
        $relativePath = $transfer->getRelativePath();

        if (!$this->documentExists($transfer, $containerName)) {
            throw new NoDocumentFoundException(
                sprintf(
                    'No File "%s" found for type %s',
                    $fileName,
                    $containerName
                )
            );
        }

        return $this->fileUploadFacade->readFileStream($containerName, $fileName, $relativePath);
    }