mavishak / cnss-embedded

1 stars 0 forks source link

Sending image to firebase #17

Open NaomiCreate opened 3 years ago

NaomiCreate commented 3 years ago

22/03/2021

Before using the camera module, we wanted to check if it would be possible to send an image to the storage (where the photos are stored on firebase) using an HTTP message.

We used the postman tool to simulate sending POST messages. We used the following link: How to upload objects to Firebase Storage using Postman for testing?

We sent the message: Post https://firebasestorage.googleapis.com/v0/b/project-cnss.appspot.com/o?uploadType=media&name=<image_name>

We attached an image file in body, and marked the body as binary.

The response we got was:

{
    "name": "image_name",
    "bucket": "project-cnss.appspot.com",
    "generation": "1616353504505877",
    "metageneration": "1",
    "contentType": "image/png",
    "timeCreated": "2021-03-21T19:05:04.534Z",
    "updated": "2021-03-21T19:05:04.534Z",
    "storageClass": "STANDARD",
    "size": "11982",
    "md5Hash": "vulhrtlw019i7nmtGIhgpA==",
    "contentEncoding": "identity",
    "contentDisposition": "inline; filename*=utf-8''image_name",
    "crc32c": "Qu+31A==",
    "etag": "CJXg3oOKwu8CEAE=",
    "downloadTokens": "a44fe9a0-a79c-44e7-a45b-5404af4e4362"
}

Note: It seems that the field that is important to us in the response is: downloadTokens. Because it's part of the image path in storage: https://firebasestorage.googleapis.com/v0/b/project-cnss.appspot.com/o/<image_name>?alt=media&token=a44fe9a0-a79c-44e7-a45b-5404af4e4362