Saturday, August 7, 2021

Google Drive api uploads file name as "Untitled"

If you are uploading a file on google drive using Google API, you might face incorrect filename issue. If uploaded filename is not the real name of the file, its name is Untitled, here is the solution for you.

You need to send metadata json with the post data. Metadata json contains filename and content type. When google api finds metadata json with the post data, it uploads the file with correct name.

Here is the tutorial to upload the file on the google drive using postman.

https://linuxamination.blogspot.com/2021/08/upload-files-on-google-drive-using.html

If you are using curl or any other scripting method to upload the files on drive, you need to send metadata json with the post data.

It will solve the issue.

Complete Solution :



Upload Files on Google Drive using Postman


SR. No.
Parameter Value
1
Request Type Post
2
URL https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart
3.1 Authorization Authorization Type Oauth2.0
3.2
Available Token <here-is-the-token>
3.3
Token Name Authorization
3.4
Grant Type Authorization Code
4.1 Headers Authorization Bearer <here-is-the-token>
4.2
Content-Type multipart/form-data; boundary=<calculated when request is sent>
4.3
Content-Length <calculated when request is sent>
4.4
Host <calculated when request is sent>
5.1 Body Key Empty
5.2
File filename.json
5.3
Key Empty
5.4
File file.png

Screenshots : (Click on image to see bigger view)


 



a) filename.json

    Content-Type: application/json; charset=utf-8
    {
      "name": "file.png",
      "mimeType": "image/png"
    }

b) file.png

    An image file

Wednesday, August 4, 2021

Run Google Chrome as root in Linux without no sandbox

If you are facing issue while running Google Chrome or other softwares as a root user on Linux systems like Ubuntu, CentOS, KALI, Fedora etc, here is the guide for you.


# Create a User for Google Chrome or other software

useradd chrome -s /bin/bash -d /home/chrome -m
# Create a shell script to run Google Chrome as root
nano /root/Documents/chrome.sh

# Add following content in the script

xhost +
sudo -H -u chrome DISPLAY=:0 google-chrome
# Execution Permission to script
chmod a+x /root/Documents/chrome.sh

 # Run the script by command line

bash /root/Documents/chrome.sh

or double click on the sh file. 

You should be able to run Chrome or other softwares like skype as a root user.