Home>

I want to download a file created with CloudFunctions.

In the function that triggers when a file is uploaded to Storage, after tampering with the file in the temp directory, how can you download the changed file directly to CloudFunctions instead of uploading it to Storage once? .

If that is not possible, I think that AngularFireStorage will be used, but AngularFireStorage seems to be the specification to get the download URL from the return value variable when I upload the file, this time final The file I want to download is different from the uploaded file, so you can't use it.
Is there no choice but to use a raw FirebaseSDK?

Please give me an answer.

  • Answer # 1

      

    How can I download directly with CloudFunctions?

    This is impossible.

      

    If that wasn't possible, I would use AngularFireStorage

    Since it was not possible, the only option is to download the necessary files from the client when needed. That's where FirebaseSDK is used.
    If you are using Angular, you can use the listed AngularFireStorage.

      

    In the function that triggers when a file is uploaded to Storage, after tampering with the file in the temp directory, instead of uploading the changed file to Storage

    Upload the new (created) file to Storage.
    As described above, the necessary files will be downloaded from the client when necessary.

      

    This time, the file you want to download finally is different from the uploaded file, so it's not possible to use it.

    Is this the subject of your work?
    In order to solve this, I think there are only the following two options.

    Make regularity to the file path after the change (Make sure to create the same file name under any directory etc.)
    Example) File path before change: hoge.jpg → File path after change: converted/hoge.jpg
    If the client uploads with hoge.jpg, make sure to go to the same file name under the converted

    Save the changed file path in a database (Firestore, Realtime Database, etc.)
    The client accesses the database in advance and confirms the location of the file