src/acdhOeaw/fedora/FedoraResource.php
public function updateContent($data, bool $convert = false) {
        if (empty($data)) {
            return;
        }
        $this->loadMetadata();
        if ($this->isA('http://www.w3.org/ns/ldp#NonRDFSource')) {
            $request = new Request('PUT', $this->getUri());
            $request = Fedora::attachData($request, $data);
            $this->fedora->sendRequest($request);
        } else if ($convert) {
            $aclRules  = $this->getAcl()->getRules(false);
            $this->uri = $this->fedora->sanitizeUri($this->uri);
            $this->delete(true);
            $newRes    = $this->fedora->createResource($this->metadata, $data, $this->uri, 'PUT');
            $this->uri = $newRes->getUri();
            // restore acl rules
            foreach ($aclRules as $rule) {
                $rule->save();
            }
        } else {
            throw new RuntimeException('Resource is not a binary one. Turn on the $convert parameter if you are sure what you are doing.');
        }
        $this->loadMetadata(true);
    }
public function updateContent($data, bool $convert = false) {
        if (empty($data)) {
            return;
        }
        $this->loadMetadata();
        if ($this->isA('http://www.w3.org/ns/ldp#NonRDFSource')) {
            $request = new Request('PUT', $this->getUri());
            $request = Fedora::attachData($request, $data);
            $this->fedora->sendRequest($request);
        } else if ($convert) {
            $aclRules  = $this->getAcl()->getRules(false);
            $this->uri = $this->fedora->sanitizeUri($this->uri);
            $this->delete(true);
            $newRes    = $this->fedora->createResource($this->metadata, $data, $this->uri, 'PUT');
            $this->uri = $newRes->getUri();
            // restore acl rules
            foreach ($aclRules as $rule) {
                $rule->save();
            }
        } else {
            throw new RuntimeException('Resource is not a binary one. Turn on the $convert parameter if you are sure what you are doing.');
        }
        $this->loadMetadata(true);
    }
public function updateContent ( $ data , bool $ convert = false ) { if ( empty ( $ data ) ) { return ; } $ this -> loadMetadata ( ) ; if ( $ this -> isA ( 'http://www.w3.org/ns/ldp#NonRDFSource' ) ) { $ request = new Request ( 'PUT' , $ this -> getUri ( ) ) ; $ request = Fedora :: attachData ( $ request , $ data ) ; $ this -> fedora -> sendRequest ( $ request ) ; } else if ( $ convert ) { $ aclRules = $ this -> getAcl ( ) -> getRules ( false ) ; $ this -> uri = $ this -> fedora -> sanitizeUri ( $ this -> uri ) ; $ this -> delete ( true ) ; $ newRes = $ this -> fedora -> createResource ( $ this -> metadata , $ data , $ this -> uri , 'PUT' ) ; $ this -> uri = $ newRes -> getUri ( ) ; // restore acl rules foreach ( $ aclRules as $ rule ) { $ rule -> save ( ) ; } } else { throw new RuntimeException ( 'Resource is not a binary one. Turn on the $convert parameter if you are sure what you are doing.' ) ; } $ this -> loadMetadata ( true ) ; }
Updates resource binary content in the Fedora.

If the resource is not a binary resource (in Fedora terms),
it can be converted.
This means the existing Fedora resource will be deleted and the new one
will be created.
This means the resource will change its Fedora URI but the id property
indicated by the "fedoraIdProp" config option (see init()) will be
preserved.
This means until you are using the id property values (and not Fedora URIs)
to denote resources in your metadata, your metadata consistency will be preserved.

@param mixed $data resource data as a string, file name
or an array: ['contentType' => 'foo', 'data' => 'bar', 'filename' => 'baz.txt']
@param bool $convert if metadata-only resource be automatically
converted to a binary one
@throws \DomainException
@see init()
Updates resource binary content in the Fedora .