有一段代码不断抛出此错误:
RuntimeException: SplFileObject::__construct(86a03f5ac14227ae4e596750c3a90db1612f77ce1b00e4aa6cbd4b2dc5e69835.icturee.jpg): failed to open stream: No such file or directory in /home/site/vendor/tray-labs/oracle-storage/src/Object/File.php:42 Stack trace: #0 /home/site/vendor/tray-labs/oracle-storage/src/Object/File.php(42): SplFileObject->__construct('86a03f5ac14227a...') #1 /home/site/vendor/tray-labs/oracle-storage/src/Service/UploadService.php(25): TrayLabs\OracleStorage\Object\File->getFile() #2 /home/site/vendor/tray-labs/oracle-storage/src/OracleStorage.php(64): TrayLabs\OracleStorage\Service\UploadService->handle('86a03f5ac14227a...', Object(TrayLabs\OracleStorage\Object\File)) #3 /home/site/includes/storageProcessor.php(15): TrayLabs\OracleStorage\OracleStorage->upload('86a03f5ac14227a...', Object(TrayLabs\OracleStorage\Object\File)) #4 /home/site/wwwroot/chumba.html(470): storeFile(Object(TrayLabs\OracleStorage\OracleStorage), '86a03f5ac14227a...', '86a03f5ac14227a...') #5 {main}我已经尽力遵循traylabs存储包的集成文档,如:
的composer.json文件中添加了这一行
require traylabs/oracle-storage
中的包
php composer.phar update
创建配置文件conf.php的
return [ 'user'=>[
'username'=>'example@gmail.com',
'password'=>'#password'
], 'account'=>[
'identifier'=>'bucket',
'auth_url'=>'https://oraclecloud.com/object-storage/buckets/f4yay/items'
], 'storage'=>[
'container'=>'items',
'local_path'=>'/home/site/wwwroot/destination/',
'cache'=>true
] ];processing.php文件,如下所示: <?php
use \TrayLabs\OracleStorage\OracleStorage;
use \TrayLabs\OracleStorage\Object\File;
use \TrayLabs\OracleStorage\ExceptionFileNotFound;
require_once("../vendor/autoload.php");
function getClient() {
$client=new OracleStorage(require '/home/site/includes/Conf.php');
return $client;
}
//utility
function storeFile($client,$filename) {
$calledname=$client->upload("$filename", new File($filename));
return $calledname;
}
?>require_once()函数将processing.php文件包含在几个products.html文件中,其中图像文件jpeg/ping等将被上传到web应用服务器,然后上传到甲骨文云对象存储中,如下所示: <?php
use \TrayLabs\OracleStorage\OracleStorage;
use \TrayLabs\OracleStorage\Object\File;
use \TrayLabs\OracleStorage\ExceptionFileNotFound;
require_once('./../includes/processing.php');
require_once("./../vendor/autoload.php");
if ($_SERVER["REQUEST_METHOD"]=="POST")
{
if ($_FILES['picha']['error'] == UPLOAD_ERR_OK)
{
$tmpName = $_FILES['picha']['tmp_name'];
$name = basename($_FILES['picha']['name']);
$ext = strtolower(substr($name, strripos($tmpName, '.')+1));
$filename = hash_file('sha256', $tmpName) . '.' . $ext;
$destination=__DIR__."/warehouse/$filename";
$message=move_uploaded_file($tmpName,$destination);
$filepath=$destination;
$contents=fopen($filepath,'r');//getfilecontents($filepath);
try
{
$client=new getClient();
$itemname=storeFile($client,$filename);
}
catch(Exception $ex)
{
$ex->getMessage();
echo $ex;
}
unlink($destination);
//some more code goes here
}
}
?>为了简洁起见,我删除了一些代码,例如html表单元素和其他特定产品的相关数据元素。
发布于 2020-02-28 07:01:20
我已经找到解决办法了。我想起了一些我应该放在清单上的东西。我只是去了我的应用程序的kudu控制台,该应用程序托管在蔚蓝应用服务中,并更改了文件夹的所有者,在那里我保存多媒体文件为www-data,不久之后,我的应用程序就像它应该做的那样顺利运行。
https://stackoverflow.com/questions/60428747
复制相似问题