elective-stereophonic
elective-stereophonic
How to upload a file using API call Upload Tagged Data
Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest Stable Nxt Client: Nxt 1.12.2

Author Topic: How to upload a file using API call Upload Tagged Data  (Read 1758 times)

besanson

  • Newbie
  • *
  • Karma: +0/-0
  • Offline Offline
  • Posts: 10
    • View Profile
How to upload a file using API call Upload Tagged Data
« on: August 28, 2017, 01:11:19 pm »

Hi,
Could someone guide me a little on how to use this API to upload a file?

19.12 Upload Tagged Data
Request:
  requestType=uploadTaggedData&
  data=d4f167249340d6d746f49441b8ccdb1bd3521feb&
  name=Stargate SG1 full series&
  description=Hash of the torrent.&
  tags=video, scifi, torrent&
  channel=torrent&
  secretPhrase=secretPhrase&
  feeNQT=100000000&
  deadline=60

Thanks in advance

Best!

Logged

VanBreuk

  • Hero Member
  • *****
  • Karma: +362/-19
  • Offline Offline
  • Posts: 2772
    • View Profile
Re: How to upload a file using API call Upload Tagged Data
« Reply #1 on: August 29, 2017, 02:23:36 am »

Hi besanson,

you can do it in different ways depending on your convenience. Assuming you're running the Nxt Client in your computer, the most straightforward way would be using your web browser, just putting all the parameters together in one line like this (using the wiki example here):

Code: [Select]
http://localhost:7876/nxt?requestType=uploadTaggedData&data=d4f167249340d6d746f49441b8ccdb1bd3521feb&name=Stargate SG1 full series&description=Hash of the torrent.&tags=video, scifi, torrent&channel=torrent&secretPhrase=secretPhrase&feeNQT=100000000&deadline=60
Replacing the example parameters with yours, and where secretPhrase would be the secret passphrase of your account.

You could also do it from unix command line using curl, like this:

Code: [Select]
curl -d "http://localhost:7876/nxt?requestType=uploadTaggedData&data=d4f167249340d6d746f49441b8ccdb1bd3521feb&name=Stargate SG1 full series&description=Hash of the torrent.&tags=video, scifi, torrent&channel=torrent&secretPhrase=secretPhrase&feeNQT=100000000&deadline=60"
« Last Edit: August 29, 2017, 09:14:13 am by VanBreuk »
Logged
GPG Fingerprint: B020 D1C1 F289 3B2C 3577  9EAD 455D D175 5913 C7F1

besanson

  • Newbie
  • *
  • Karma: +0/-0
  • Offline Offline
  • Posts: 10
    • View Profile
Re: How to upload a file using API call Upload Tagged Data
« Reply #2 on: August 29, 2017, 08:56:21 am »

H1 VanBreuk,

Thanks! I have problems to see how can i attach a file (pdf less than 40kb). That would be the paremeter: &data=d4f167249340d6d746f49441b8ccdb1bd3521feb& ?

I'm using ajax to make api calls. But when i reach the parameter data i dont know what to put there.

I am a little bit loss here

Thanks in advance

Best!

Logged

VanBreuk

  • Hero Member
  • *****
  • Karma: +362/-19
  • Offline Offline
  • Posts: 2772
    • View Profile
Re: How to upload a file using API call Upload Tagged Data
« Reply #3 on: August 29, 2017, 09:30:41 am »

See the reference for the uploadTaggedData API call at https://nxtwiki.org/wiki/The_Nxt_API#Upload_Tagged_Data besides the example case provided. There's the option to include file information.

If figuring out the parameters needed for an API call seems too confusing, you may want to test first using the Nxt Client, Data Cloud section, File Upload button. Also keep in mind that you can access all the available API calls as categorized forms in http://localhost:6876/test when running your testnet client.
Logged
GPG Fingerprint: B020 D1C1 F289 3B2C 3577  9EAD 455D D175 5913 C7F1

besanson

  • Newbie
  • *
  • Karma: +0/-0
  • Offline Offline
  • Posts: 10
    • View Profile
Re: How to upload a file using API call Upload Tagged Data
« Reply #4 on: August 29, 2017, 01:11:03 pm »

Hi! I dont know what reference you mean. It sends you back to the call that i copy initially.  I cant find the "option to include file information" in the call.
Request:
  requestType=uploadTaggedData&
  data=d4f167249340d6d746f49441b8ccdb1bd3521feb&
  name=Stargate SG1 full series&
  description=Hash of the torrent.&
  tags=video, scifi, torrent&
  channel=torrent&
  secretPhrase=secretPhrase&
  feeNQT=100000000&
  deadline=60

I just want to make a message with attachment.
You mean is better to upload before the to Data Cloud and then copy the hash: like d4f167249340d6d746f49441b8ccdb1bd3521feb& ?

Thanks in advance!

Logged

VanBreuk

  • Hero Member
  • *****
  • Karma: +362/-19
  • Offline Offline
  • Posts: 2772
    • View Profile
Re: How to upload a file using API call Upload Tagged Data
« Reply #5 on: August 29, 2017, 02:57:10 pm »

Please check again the link in my previous post. It takes to the description of the API call parameters, you are quoting the example which is linked below the description.

Quote
19.12 Upload Tagged Data

Upload and broadcast new tagged data. POST only.

Request: Refer to Create Transaction Request for common parameters.

requestType is uploadTaggedData
data is the data (optional)
file is the pathname of a data file to upload (optional if data provided)
filename is a filename to associate with data (optional if file uploaded in which case the uploaded filename is always used)
name is the name or title of data (optional if file uploaded in which case the uploaded filename is used, but name takes precedence if provided)
description is a description of data (optional)
tags is a list of up to 5 words from 3 to 20 characters long and separated by spaces and/or commas, describing the actual content of data; for example: audio,mp3,classical (optional)
type is the mime type of data such as torrent, pdf, doc, image, etc. (optional)
channel is a data feed label such as pirate bay torrents, wikileaks, etc. (optional)
isText is false if data is a hex string (optional)

Note: The maximum length of data plus all associated metadata is 42 kilobytes. The maximum length of description is 1000 bytes. The maximum length of the other metadata (name, tags, type, channel and filename) is 100 bytes each.

Do check the link however, the format is easier to read than here.
Logged
GPG Fingerprint: B020 D1C1 F289 3B2C 3577  9EAD 455D D175 5913 C7F1

besanson

  • Newbie
  • *
  • Karma: +0/-0
  • Offline Offline
  • Posts: 10
    • View Profile
Re: How to upload a file using API call Upload Tagged Data
« Reply #6 on: August 30, 2017, 07:31:16 am »

Hi! Yes thank. But still cant figure out how this call should be written. Sorry newbie :)
Thanks for your support! I will not bother again
Logged
 

elective-stereophonic
elective-stereophonic
assembly
assembly