Uploading animated GIF to Imgur API returns "Unable to determine file duration" error - http

I want to upload an animated GIF file to Imgur through their API but get an error message.
The file is converted from an mp4-file with GifTuna and is 15s duration, 30 FPS, ~70 MB.
I use the following command from the Windows 10 command line:
curl -X POST -H "Authorization: Bearer [MYTOKEN]" -F "video=#myfile.gif" https://api.imgur.com/3/upload
Instead of an http status code 200, it returns the error message:
{"status":400,"success":false,"data":{"error":"Unable to determine file duration","request":"/3/upload","method":"POST"}}
If I upload the original mp4-version, the upload is successful. If I try to upload the animated GIF through Imgurs own postman.com collection I get the same error message as with curl.
It doesn't seem to be a file size issue as the limit for videos is 200MB. Also, trying with a bigger file, say 300 MB, triggers a specific error stating the file is too big.
Any idea how to solve this?

Related

Error: Chunks are uploading as empty strings

I have WP and whenever I try to uplod 2-7GB mp4 video file I get that error...
enter image description here

Process ends with 100% progress and error while using pre-signed url for images

Using Mac, language .NET
Photoscene ID : krb1VCLBHop1AdbAdPtm96PWtCfsbncmfSXdSG5eUYM
I'm trying to upload images from mobile device to create 3d model of an object.
There were some issues uploading local images directly, so I uploaded images on AWS S3 and generated pre-signed url. These urls were used within file uploading curl command.
curl -v $BASE'photo-to-3d/v1/file'
-H 'Authorization: Bearer '$AUTH
-F "photosceneid="$PID
-F "type=image"
-F "file[0]="$URL
the result shows no error msg.
{"Usage":"2.1651990413666",
"Resource":"\/file",
"photosceneid":"krb1VCLBHop1AdbAdPtm96PWtCfsbncmfSXdSG5eUYM",
"Files":{"file":[{"filename":"YXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyMTEwMDdUMDY0NTU0WiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmWC1BbXotU2lnbmF0dXJlPWUyMDgyYWE2YjgyNzFmNzk4NTFmNzc3MzkwYmFhN2ExN2FjM2Y5MjJjNjM3NGIyMzg5YWFmN2IwNzE3OTY3MjU=.jpg",
"fileid":"AALxKyQX1tAhcEgbM6w6lITCOHAleS1Dumu6ocy3qaY=-krb1VCLBHop1AdbAdPtm96PWtCfsbncmfSXdSG5eUYM",
"filesize":"187126",
"msg":"No error"}
Processing ends with error
{"Usage":"0.51469397544861",
"Resource":"\/photoscene\/krb1VCLBHop1AdbAdPtm96PWtCfsbncmfSXdSG5eUYM\/progress",
"Photoscene":{"photosceneid":"krb1VCLBHop1AdbAdPtm96PWtCfsbncmfSXdSG5eUYM",
"progressmsg":"ERROR","progress":"100"}}
File links were checked. Images were displayed right and can be downloaded.
Format is jpg.
checked photoscene properties and found error_msg_id
"error_msg_id":"262"
the meaning of error code was not found anywhere including error handling documentation
I don't know what to do from here since error message does not specify what exactly went wrong.

R - Cannot Download gz file from FTP Server

I have been trying for three days now to download a file from an FTP server with R without a result. I have really tried everything and read all questions but still cannot manage.
The url is:
u <- "ftp://user:password#109.2.160.55/AGLO/2020/10/AGLO_00001_03-0_GDBX_1000077_202010032206_860101.CSV.gz"
When I copy paste this link in Firefox I can download the file, but with R I cannot. I tried download.file, GET, writeBin, getURL. All failed: getURL gives the following error:
Error in curlPerform(curl = curl, .opts = opts, .encoding = .encoding) :
embedded nul in string: '\037‹\b\bøÙx_\0\003AGLO_00001_03-0_GDBX_1000077_202010032206_860101.CSV\0¬\\M³£¸’Ý¿_Áî­º\002I Xɶ®­*\fn>nÔ­MÇ›\231·èͼ\210î×\021óóç¤\004\006#¹.Œ§+¢ë’צŽ’TæÉ\017¡ÎUS*üï·\030ÿ±ßbñKüÛùtøþ\033#A–ýÆc\036ãgÁy,\177Ë%~f_ŽÝ{é~,é\v%}¡\\~ÐIN¿ÿùï?~ÿ\217¿þýÏ¿þ(\017±\034oY¾ýë¯?þû÷?ÿ$qù·Å/p\v÷\177{£òð]U½.umÊ¿\235»¦/{s~ƒ”\220–7ÓŸ¢Ã¿þø¯\177þã¯ÿ)ó¸ÈŠ\022_eEœã·îúz-K\031—í £¯ZÕÑW5´º+…H9/{Uéú¨K^BfNôsT©è]·­n\215ŽÊ2\021œ©²¦¯”e/æ»7e\fIy‹\231Ä_"ayF?ÈñÏýsåQUGüâ3ô¼H’d\t\177\024Hàgœ•ê=ºªópR„\235笼\002á¹VÇ\aðºRFy°y\b6Ç_xz¹d¯Àf<—I2Â.\030›\004\f°3\002­ZÓõ#\027\035Z£ê\023ÀDz(+\\7CwT}ÉJ\215¿»nè£þ¢\201\230Ô^>"§\033×ø3#çLäž¾éc›õ\035§‰`wàr\022\020pg-êøë »èÖjØCï\003çeý÷\037j\210êoM}n"ÝG׫ÆCÂ:£úï]S«è¢a_*°\034¹Z\016\036C\034XŽÜ¼œBð8YX\217»&ã‘\t=†›êz=´X…`yyÓ]g-G\177é¾Ü¾(ü颶9`\235Ñ­\031ÎXË\016\033*RÚwÏmèûgàešf|\001Þ]\023xžYËï/F·\235}\004p\tM{Òj\200·);ݾ\033\230ýE\003úY_u\215‡`j,´Û¾\0^°8}iëf<\023Kå\217\002,àP2a­Éß\006‚%åM\r¦ªì“¸Ý`jã%°“{ú±AùiÊ_s;ô_ºÄî\004Öí0\vý4ÜTÿá+ÿÚœL5þv‡¹0ž’ÃxÁ夒\025l\
There is no proxy problem whatsoever since to get the u url I am searching in the FTP directory.
How can I download this fing file ?
Also another way I could eventially work around this is using:
browseURL(u,
browser = "C:/Program Files (x86)/Mozilla Firefox/firefox.exe")
The issue with this is that it will open a Firefox browser that will:
Ask me if I am sure I want to go to this site and then
Ask me what I want to do with this file (not so much of a problem since I can choose a default to always download, but still I do not want to)
The issue with this is that simply I do not want to open a browser and I do not want to be asked if I want to go to the site and if I want to download. There are many files on this server so I want to do all of this automatically and I will need to be working in parllel, so having a browser pop up is not great, but if all else fails I can accept.
I am so desperate that I can give you the user name and password in private.
Apparently downloading the file to disk using httr solved the problem. It is possible to combine write_disk and httr::GET to download files to disk in the following way:
library(httr)
to_download <- "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
# Download pdf to disk
GET(to_download, write_disk("dummy.pdf"))

How to authenticate myself to download data in R?

I want to download secured data from LendingClub (a P2P lending company, please Google it if you're interested in what they do).
The secured data can only be downloaded if you have an account. So now I have a username and password, and I check the download page to copy the file download link. Then how can I authenticate myself to download the data? I tried the following:
file <- 'lc1'
url <- "https://www.lendingclub.com/fileDownload.action?type=gen&file=LoanStats3a_securev1.csv.zip"
download.file(url, file)
But it throws warning:
trying URL 'https://www.lendingclub.com/fileDownload.action?type=gen&file=LoanStats3a_securev1.csv.zip'
Content type 'text/html;charset=UTF-8' length 200 bytes
opened URL
downloaded 14 Kb
Warning message:
In download.file(url, file) :
downloaded length 14531 != reported length 200
And the text file downloaded is not the zip file I want, I guess it's because no authentication step is involved, because if you don't have an account you can also download the partial data and the link is different:
url <- "https://resources.lendingclub.com/LoanStats3a.csv.zip"
and previous commands would work fine. So where can I add the authentication step?
You'll have to use their REST API with an API key that they give you here.
Then you can build a URL to the resource that you're looking to download in the format you'd like it in (or a format that you can manipulate to use in your code).
You can use curl to double-check your URL:
$curl -v -H "Authorization: <api key>" -XGET https://api.lendingclub.com/api/investor/v1/accounts/<investor_id>/summary

R Import - CSV file from password protected URL - in .BAT file

Okay - so here is what I'm trying to do.
I've got this password protected CSV file I'm trying to import into R.
I can import it fine using:
read.csv()
and when I run my code in RStudio everything works perfect.
However, when I try and run my .R file using a batch file (windows .bat) it doesn't work. I want to use the .BAT file so that I can set up a scheduled task to run my code every morning.
Here is my .BAT file:
"E:\R-3.0.2\bin\x64\R.exe" CMD BATCH "E:\Control Files\download_data.R" "E:\Control Files\DailyEmail.txt"
And here is my .R file:
url <- "http://username:password#www.url.csv"
data <- read.csv(url, skip=1)
** note, I've put my username/password and the exact location of the CSV in my code. I've used generic stuff here, as this is work related and posting usernames and passwords is probably frowned upon.
As I've said, this code works fine when I use it in RStudio. But fails when I use the .BAT file.
I get the following error message:
Error in download.file(url, "E:/data/data.csv") :
cannot open URL 'websiteurl'
In addition: Warning message:
In download.file(url, "E:/data/data.csv") :
unable to resolve 'username'
Execution halted
** above websiteurl is the http above (I can't post links)
So obviously, the .BAT is having trouble with the username/password? Any thoughts?
* EDIT *
I've gone so far as trying this on Linux. Thinking maybe windows was playing silly bugger.
Just from the terminal, I run Rscript -e "download_data.r" and get the EXACT same error message as I did in Windows. So I suspect this may be a problem with where I'm getting the data? Could the provider be blocking data from the command line, but not from with Rstudio?
I have had similar problems which had to do with file permissions. The .bat file somehow does not have the same privileges as you running the code directly from Rstudio. Try using rscript (http://stat.ethz.ch/R-manual/R-devel/library/utils/html/Rscript.html) within your .bat file like
Rscript "E:\Control Files\download_data.R"
What is the purpose of the argument "E:\Control Files\DailyEmail.txt"? Is the program suppose to use it in any way?
So, I've found a solution, which is likely not the most practical for most people, but works for me.
What I did was migrated my project over to a Linux system. Running daily scripts, is easier on Linux anyways.
The solution makes use of the "wget" function in linux.
You can either run the wget right in your shell script, or make use of the system() function in R to run the wget.
code looks like:
wget -O /home/user/.../file.csv --user=userid --password='password' http://www.url.com/file.csv
And you can do something like:
syscomand >- "wget -O /home/.../file.csv --user=userid --password='password' http://www.url.com/file.csv"
system (syscommand)
in R to download the CSV to a location on your hard drive, then grab the CSV using read.csv()
Doing it this way gave me some more insight into the potential root cause of the problem. While the system(syscommand) is running, I get the following output:
Connecting to www.website.com (www.website.com)|ip.ad.re.ss|:80... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Reusing existing connection to www.weburl.com:80.
HTTP request sent, awaiting response... 200 OK
Not sure why it has to send the request twice? And why I'm getting a 401 Unauthorized the first try?

Resources