GraphQL API and utilities for the rpdata project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
593 B

  1. package files
  2. import (
  3. "time"
  4. "git.aiterp.net/rpdata/api/models"
  5. )
  6. // Insert manually inserts file information into the database. This should never, ever be HTTP API accessible
  7. func Insert(name, kind, mimeType, author string, time time.Time, size int64, url string) (models.File, error) {
  8. file := models.File{
  9. ID: makeID(),
  10. Kind: kind,
  11. Time: time,
  12. Public: false,
  13. Author: author,
  14. Name: name,
  15. MimeType: mimeType,
  16. Size: size,
  17. URL: url,
  18. }
  19. err := collection.Insert(file)
  20. if err != nil {
  21. return models.File{}, err
  22. }
  23. return file, nil
  24. }