Home>

S3 Consider the file acquired from the server and the uploaded file
The following code was created.

Public Function UploadJoin (Request $ Request)
{
    $ file= $ Request->
File ('file');
    $ CONTENT= \ Storage :: Disk ('S3')->
get ($ file_name);
    $ DATA= FILE_GET_CONTENTS ($ CONTENT);
    $ DATA.= file_get_contents ($ file);
    \ Storage :: Disk ('S3')->
PUT ($ file_name, $ DATA);
    RETURN [
        'Message'= >
 'OK',
    ];
}

But file combining "file_get_contents () Expects Parameter 1 to Be A Valid Path" is not able to join because errors can not be combined.
How do I treat files acquired from the S3 server as binary data?

Thank you.

"I'm not going to go well" I think that it is difficult to have a detailed answer if it is specifically what kind of situation and information such as file format. /Also, if you focus on "File Binding", the problem is that the code that has not been added from "S3" is not simpler.

cubick♦2021-05-12 21:48:43

Here, "file_get_contents () Expects Parameter 1 to be a Valid Path" and an error occur.

Nax藤極2021-05-12 21:48:43

Please check how to use file_get_contents once. The argument should pass a URL or file path, but your code feels that the contents of the file are directly passed.

cubick♦2021-05-12 21:48:43
  • Answer # 1

    Let's look at the return value of the get method.

    Public Function Get ($ PATH, $ LOCK= FALSE)
    {
        IF ($ this->
    isFile ($ PATH)) {
            RETURN $ LOCK? $ this->
    SharedGet ($ PATH): file_get_contents ($ PATH);
        }
        Throw New FilenotFoundException ("File Does Not Exist at Path {$ Path}.");
    }
    
    

    $ LOCKBut,tRUEIfSharedGet Method,falseIfFILE_GET_CONTENTS FunctionYou can see that you are returning the return value of.

    $ LOCKIs a specified valuefalseFor this case,FILE_GET_CONTENTS FunctionReturn value of the presentation$ CONTENTIt will be assigned to

    How do you say?
    GET methodThe return value of the first argument file is the content , soFILE_GET_CONTENTS FunctionIf you put it in, it will be an error that says "not such a file!"

  • Answer # 2

    Let's look at the return value of the get method.

    Public Function Get ($ PATH, $ LOCK= FALSE)
    {
        IF ($ this->
    isFile ($ PATH)) {
            RETURN $ LOCK? $ this->
    SharedGet ($ PATH): file_get_contents ($ PATH);
        }
        Throw New FilenotFoundException ("File Does Not Exist at Path {$ Path}.");
    }
    
    

    $ LOCKBut,tRUEIfSharedGet Method,falseIfFILE_GET_CONTENTS FunctionYou can see that you are returning the return value of.

    $ LOCKIs a specified valuefalseFor this case,FILE_GET_CONTENTS FunctionReturn value of the presentation$ CONTENTIt will be assigned to

    How do you say?
    GET methodThe return value of the first argument file is the content , soFILE_GET_CONTENTS FunctionIf you put it in, it will be an error that says "not such a file!"

  • Answer # 3

    If you translate the error, you feel that you specify a valid path for the first parameter of file_get_contents (), so I think that the file_get_contents () parameter is simply incorrect.
    Did you confirm the specification of the function?
    PHP: file_get_contents-Manual

  • Answer # 4

    If you translate the error, you feel that you specify a valid path for the first parameter of file_get_contents (), so I think that the file_get_contents () parameter is simply incorrect.
    Did you confirm the specification of the function?
    PHP: file_get_contents-Manual