How to read the content of a file in a GitHub public repo - api

I am trying to use the GitHub API documented in https://developer.github.com/v3/repos/contents to read the content of a file. According to the document, it is to use "GET /repos/:owner/:repo/contents/:path". So I am trying to figure out how to actually use this API.
I am using Postman to test this API. For example, the owner name is "babybee", the repo name is "test_repo", what's the complete url for this? I tried "/repos/babybee/test_repo/contents/release/release_info.json" and obviously it doesn't work. Let's say, if the file path is "release/release_info.json" under root path, what would the actual complete url be for it to be working?

For the owner babybee, repo test-repo and file release/release_info.json, to get the contents, you should be using the API as below:
https://api.github.com/repos/babybee/test-repo/contents/release/release_info.json

Related

How to upload a file using postman

I'm trying to translate some CURL code on postman to upload a file on a server.
I have a key called "file" which is the file I want to upload.
On postman, when I pass him the file path, it doesn't work (the api rejects me).
On the other hand, when I tell postman that I want to send him a "file" and that I select the file, it works.
Why does it work when I select the file from postman and why doesn't it work when I pass him the path to my file on my computer?
When I give the path to the file (it doesn't work)
When I select the file from postman (it works)
Postman must be doing something in the background that I do not know and do not know ... And I need to know what it is doing so I can use it in my application
Thanks for your attention and your help ! :)
yes you are right postman does that internally.
https://i.stack.imgur.com/bWs6a.png
here you are passing the file path as string but we need to send the file data
https://i.stack.imgur.com/cGg1r.png
here as you pick a File instead of text postman know that you have entered the file path from there postman read that's file and sends the whole file data
for more understanding, you can check code snippets of different languages
NodeJs - Axios
var data = new FormData();
data.append('file', fs.createReadStream('/Users/filename.txt'));
Well, I found the answer, not using the curl ^^
My provider who developed this CURL script explained me that it was old and unusable today.
So I use a sftp server.
Thanks for your answers I have read them :)

DownLoad VichBundle file Api Platform

I'm using API platform with VichBundle to store file on the back side and React Native on the Front side.
I've followed the documentation of API platform and the upload part is working well, but I don't know how to download the document.
When I make a GET request I have the entity with the url of the file but I can't do a GET request with this url because there is no route to this file.
Can somebody give me an exemple of how to download file with api platform and Vichbundle.
Thanks
If you are following Api Platfom's documentation your files should be uploaded to your project's ./app/public/media/ folder and available making an HTTP GET request to http(s)://<yourdomain>/public/media/<filename>.<extension>. Just open the URL in your browser.
To get the exact url query yout API for me mediaObject information (for example, /api/media_objects/{id}) and check the contentUrl property.

How to get complete path or URL of a File in Dropbox?

I am uploading bulk files using Dropbox .NET API.
I want that after uploading the file how to get a complete path or URL like - "https://www.dropbox.com/work/Apps/*****/testinng234/1.mp3". So that I can able to use this link directly.
Please suggest me the best way and share some code.

How to Upload PhantomJS Page Content to S3

I am using PhantomJS 1.9.7 to scrape a web page. I need to send the returned page content to S3. I am currently using the filesystem module included with PhantomJS to save to the local file system and using a php script to scan the directory and ship the files off to S3. I would like to completely bypass the local filesystem and send the files directly from PhantomJS to S3. I could not find a direct way to do this within PhantomJS.
I toyed with the idea of using the child_process module and pass in the content as an argument, like so:
var execFile = require("child_process").execFile;
var page = require('webpage').create();
var content = page.content;
execFile('php', '[path/to/script.php, content]', null, function(err,stdout,stdin){
console.log("execFileSTDOUT:", JSON.stringify(stdout));
console.log("execFileSTDERR:", JSON.stringify(stderr));
});
which would call a php script directly to accomplish the upload. This will require using an additional process to call a CLI command. I am not comfortable with having another asynchronous process running. What I am looking for is a way to send the content directly to S3 from the PhantomJS script similar to what the filesystem module does with the local filesystem.
Any ideas as to how to accomplish this would be appreciated. Thanks!
You could just create and open another page and point it to your S3 service. Amazon S3 has a REST API and a SOAP API and REST seems easier.
For SOAP you will have to manually build the request. The only problem might be the wrong content-type. Though it looks as if it was implemented, but I cannot find a reference in the documentation.
You could also create a form in the page context and send the file that way.

Get Dropbox public folder's metadata without authentication

I'm about to create a blog and wanted to host the content on Dropbox (only Markdown files, everything else is on my server) because I want to be able to quickly upload and edit posts from all my devices without having to get some FTP app on them.
So far I managed to access files via https://dl.dropboxusercontent.com/u/********/<sub-folder>/<file name>.md and like pointed out here I can get the last-modified attribute via etags.
However, I'm stuck at getting a file list (or a folder's metadata in general). Is this possible without using OAuth?
No, this isn't possible without using the API. But why are you against using the API?
Feel free to use my tool https://dbxoauth2.site44.com/ to get an OAuth access token for your account. Then just do an HTTP GET to https://api.dropbox.com/1/metadata/auto/<path> with an Authorization header of Bearer <token>. Ditto for getting the actual file contents, just use /files/auto/<path> instead.
Oh, unless you're doing this client-side in JavaScript? In that case, this won't work since you can't give your access token out to the client (where it could be abused by anyone who visited your website).
make "Public" folder and go https://www.dropbox.com/enable_public_folder
back to your dropbox folder (web) right mouse at file in public folder and chose "Copy public link..."
Update: As of September 1, 2017 public links have been disabled for all users.
https://help.dropbox.com/files-folders/share/public-folder